MATLAB: Problem with sine-wave and scope component in simulink

scope componentsimulinksimulink componentssine-wave component

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.

Best Answer

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.