Getting output data from Simulink

3 ビュー (過去 30 日間)
Wei Yang Shen
Wei Yang Shen 2020 年 11 月 29 日
コメント済み: jessupj 2020 年 12 月 1 日
I have a simulink model that runs for 600 time steps and I want to get the output data from the scopes. I set the scope parameters to logging to workspace but when I check my workspace, the output data only has 192 data points. How do I get the values for each time step (getting 600 data points where each point corresponds to a time step).
  7 件のコメント
Wei Yang Shen
Wei Yang Shen 2020 年 11 月 30 日
It seems that I get 292 points from 0 to 600 and it seems it increases by 12 each time except the 2 and 3 values which do not seem to follow this pattern. To reply to jessupj, this was originally a script that called ode45 on a matlab function so when I converted it to simulink I just used a matlab function block. I also have demultiplexers to break up the output matricies into individual scopes.
Fangjun Jiang
Fangjun Jiang 2020 年 11 月 30 日
No need to provide wild guesses like "extra data points are getting truncated" or "it seems it increases by 12 each time". You expect to see 600 data points based on your understanding (which is incorrect). You received 192 data points in one case and 292 data points in another case. This can be explained by the fact that you are using variable time step solver.
You can learn about variable time step solver by right click at "Solver" and select "What's this".
Other than that, there is really no problem. If your simulation results are correct, they are correct.

サインインしてコメントする。

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2020 年 12 月 1 日
The different size of the logged data is caused by the variable-step solver. To get a consistent and fixed size log data, use a fixed-step sover.
  1 件のコメント
jessupj
jessupj 2020 年 12 月 1 日
i agree: using a fixed timestep solver is the solution here to the OP's problem as stated.
however, it depends on the system. sometimes it's better to interpolate the output of variable timestep solvers to the time points you want; fixed timesteps can be extremely inefficient and/or won't work for stiff problems.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSources についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by