problem with sine-wave and scope component in simulink
49 views (last 30 days)
Show older comments
i'm a begginer and trying to learn simulink. following a sample on mathworks site i put a sine-wave and a scope in a simple model. the problem is the shape of sine-wave if remain the frequency at 1 the sine-wave shape is correct but if change the frequency it'll not become like a sine-wave more like a distortion or ramp. i don't know what is the problem.
1 Comment
Leopoldo Pavesi
on 6 Nov 2019
I had the same problem. I regularly use without any problems matlab and simulink for my automatic control lectures, but i needed to generate a sine wave and was frustrated. I believe Kaustubha has given way tp overcome this situation. Many thanks to her
Accepted Answer
Kaustubha Govind
on 2 Dec 2011
I think the issue is that Simulink is not using a small enough time-step so that the signal is completely rendered on the scope (think of it like an aliasing effect). See Choosing a Solver for more information on you should configure the solver used for your model (which is what determines what time-step Simulink uses). Since you are a beginner, I'm assuming that you are using the default solver, which is a variable-step ode45 solver (from the model menu, Simulation->Configuration Parameters...>Solver). As you can seen, the "Max step size" parameter is set to "auto" by default, which means Simulink automatically tries to determine how large a step it can take so as to preserve your signal's shape - which is why, you probably see that the general shape of the signal is preserved, but details are lost. You can restrict this to a small value (say 0.01), save the new settings and try simulating again. If you still some distortion, lower the value further - at some point it should give you the signal shape you expect.
15 Comments
More Answers (2)
Salman
on 9 Sep 2025
Edited: Salman
on 9 Sep 2025
Choosing Maximum Step Size in a Simulink Solver
Example model: Sine Wave Block → Scope Block
When using a sine wave block with frequency 10 rad/sec, the signal often looks not smooth in the Scope.
This happens because Simulink automatically chooses a maximum step size = 0.2, based on three built-in MATLAB rules:
1. Step size < Period ÷ 3
- Frequency = 10 rad/sec → Period = 1/f = 0.6 sec
- Period ÷ 3 = 0.2 sec
2. Step size < (Stop Time – Start Time) ÷ 50
- (10 – 0) ÷ 50 = 0.2 sec
3. Step size must be a fraction of (Stop Time – Start Time)
- Examples: 0.1, 0.2, 0.05, etc.
So with step size = 0.2 sec:
Points per sine cycle = Period ÷ Step size = 0.6 ÷ 0.2 = 3 points per cycle
But 3 points per cycle are not enough for a smooth sine wave.
For smooth display: use 50–100 points per cycle
Better step size choices:
0.6 ÷ 50 = 0.01 sec → smoother wave
0.6 ÷ 100 = 0.006 sec → even smoother wave
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!