How to get a sin function in simulink

62 views (last 30 days)
Oskar
Oskar on 15 Dec 2017
Answered: Star Strider on 15 Dec 2017
I need a sin function in Simulink to calculate something like 5sin((x/20000)t). I have tried to create a function with 5*sin((u(1)/20000)*t) but I get a syntax error.
edit: I actually need to add two signals 5sin((x/20000)t) and 10cos((x/30000)t)

Answers (2)

Jim Riggs
Jim Riggs on 15 Dec 2017
Edited: Jim Riggs on 15 Dec 2017
I'm a little confused by the problem statement. Inside the sine function you have x/2000 * t. I'm not sure which represents the independent variable (i.e. is it a function on x or t? Is it a function on t where x is a constant?) I will assume that the function is based on time, t and x is a coefficient.
In Simulink you have a couple of choices. First is the "sin trigonometric function" block. This block simply performs the sin function on the input signal. Assuming the input signal is time, you will have to construct an input signal with a gain (multiplier) of x/2000, then multiply the output by 5 to get {5 sin (x/2000 t)}
Another option is to use the "sine wave function" block. This block has settings for "amplitude", "bias", "Frequency", and "Phase".
Set Phase to zero for a sine function, and to pi/2 for a cosine function.

Star Strider
Star Strider on 15 Dec 2017
Try this:

Categories

Find more on Simulink in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!