MATLAB Answers

Simulink: How to get a cosine wave with 'time dependent frequency'

16 views (last 30 days)
Preetham Narayana Reddy
Preetham Narayana Reddy on 3 Aug 2017
Answered: Omur Bas on 30 Aug 2017
I want to generate a cosine wave with the following equation.
x(t) = cos((wc + wx)t) where wx = w0 * cos(wm * t)
The values of wc,w0,wm are known and can be hardcoded. I am not able to put in the time dependency 't' in wx

Answers (2)

Meeshawn Marathe
Meeshawn Marathe on 9 Aug 2017
To implement this in Simulink, you can try using the "MATLAB Function" Block or the "Interpreted MATLAB Fcn" block. In addition, you would require an input block (In1), found in Simulink Sources.
Define a vector for time "t" (Ex: t=(0:0.01:10)') in the workspace. Go to Configuration Parameters -> Data Import/Export, select input and add [t,t] in the box. (One value of "t" is for simulation time and the other is for the input In1).
If you use a MATLAB function block, you can define the constants within it and write the cosine expression. If you use the other block, you would have to enter the constant values in the command prompt prior to running the model. Connect In1->Fcn block->Scope

Omur Bas
Omur Bas on 30 Aug 2017
To find time explicitly in Simulink, you can use the "Clock" block.



Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!