problem with sine-wave and scope component in simulink

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 commentaire

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

Connectez-vous pour commenter.

 Réponse acceptée

Kaustubha Govind
Kaustubha Govind le 2 Déc 2011

20 votes

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 commentaires

shmd
shmd le 3 Déc 2011
thank you that was the exactly problem
Very helpful reply :)
great..tnx
thank you..
Thank You....
E S
E S le 14 Sep 2018
I was in a hurry and it helped me a lot! Thank you!
brn ny
brn ny le 26 Sep 2018
Modifié(e) : brn ny le 26 Sep 2018
yes it worked..thanks Kaustubha. reduce the max step size .if it doesn't work...keep decreasing (even up to 0.00001)
Thank you very much for the question and for the answer from Kaustubha. I suffered from the same problem for a long period. Now, it is resolved. Thanks again.
Thank you very much
Thank you very much Kaustubha.
Amazing, worked a treat. Thank you so much!
yes it really helped, thanks. We need more people like you to help MATLAB community
Thank you. It works.
I express my heartfelt gratitude.
You are a god send. Thank you so muchhhhhhhh

Connectez-vous pour commenter.

Plus de réponses (2)

Salman
Salman le 9 Sep 2025
Modifié(e) : Salman le 9 Sep 2025

0 votes

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

Community Treasure Hunt

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

Start Hunting!

Translated by