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

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

댓글을 달려면 로그인하십시오.

 채택된 답변

Kaustubha Govind
Kaustubha Govind 2011년 12월 2일

20 개 추천

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

thank you that was the exactly problem
Very helpful reply :)
great..tnx
thank you..
Thank You....
I was in a hurry and it helped me a lot! Thank you!
brn ny
brn ny 2018년 9월 26일
편집: brn ny 2018년 9월 26일
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

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Salman
Salman 2025년 9월 9일
편집: Salman 2025년 9월 9일

0 개 추천

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

카테고리

도움말 센터File Exchange에서 Simulink에 대해 자세히 알아보기

질문:

2011년 12월 2일

편집:

2025년 9월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by