problem with sine-wave and scope component in simulink
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
More Answers (2)
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
Categories
Find more on Scopes and Data Logging 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!