Simulation Time in Simulink

14 次查看(过去 30 天)
Williams
Williams 2022-5-13
回答: Vinay 2024-9-24,9:23
Hello, I describe the general scenario of my problem below:
I used the sine wave formula to generate a sequence of points which follow a sinewave shape (using a period of 20s and dividing this into 880 linearly space points). Plotting the values of the time variable (used for this computation) against the output (sinewave function) gives a sinewave shape, as expected.
Then I used the repeating sequence block in Simulink to try to repeat this shape as many times as possible. However, the resulting shapes are bizzare as I increase the Simulation time in Simulink. The only time when it is the same as the original shape is when the Simulation time in Simulink is the same as the total time I used in the computation of the Sine wave, as its period. The figures are attached below.
  1. plot using matlab
  2. figure from the scope connected to Simulink Repeating Sequence Block with the Simulation time set to 20s
  3. figure from the scope connected to Simulink Repeating Sequence Block with the Simulation time set to 100s
  4. figure from the scope connected to Simulink Repeating Sequence Block with the Simulation time set to 200s (zoomed into a couple of cycles in order to show the non-smoothness of the curve)
Please help me understand this. Is there some downsampling taking place somewhere, and where if so?
I will appreciate your help in making me understand this behaviour. Thank you.

回答(1 个)

Vinay
Vinay 2024-9-24,9:23
Hi Williams,
The problem with the repeating sequence block arises because the solver's step size changes when the simulation time of the model is adjusted.
The variable step solver chooses a step size that exceeds the data's sampling period, causing it to miss data points and resulting in a distorted plot.The issue can be resolved by using a fixed step solver with step size less than the sampling period of the data.
Kindly refer to the below documentation of “solver” for more details:
I hope this helps!

类别

Help CenterFile Exchange 中查找有关 Sources 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by