Getting output data from Simulink

2 views (last 30 days)
Wei Yang Shen
Wei Yang Shen on 29 Nov 2020
Commented: jessupj on 1 Dec 2020
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 Comments
Wei Yang Shen
Wei Yang Shen on 30 Nov 2020
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 on 30 Nov 2020
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.

Sign in to comment.

Answers (1)

Fangjun Jiang
Fangjun Jiang on 1 Dec 2020
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 Comment
jessupj
jessupj on 1 Dec 2020
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.

Sign in to comment.

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!