Getting output data from Simulink
显示 更早的评论
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 个评论
Mathieu NOE
2020-11-30
hello
maybe you have a time axis or a buffer size of your scope that limits the display and the "to worksapce" to this limit
why not put beside the scope a specific "to workspace" block and tune the block parameters to get the right amount (and structure) of data
Fangjun Jiang
2020-11-30
I suspect you have variable time step, so if you have minimum time step as 0.1 and run simulation for 60 seconds, it is not going to be "600 time steps". Log simulation time first to check it out.
Wei Yang Shen
2020-11-30
编辑:Wei Yang Shen
2020-11-30
i second the variable timestep notion. if you write the output to a matrix (a different 'sink' block'), the output should be a timeseries equivalent to the data setn to the scope. the time points are determined by the solver and solver settings unless you have some other blocks or signal buffers in there. you've provided no information on those.
Fangjun Jiang
2020-11-30
Press Ctrl+E, on the left, click "Data Import/Export", on the right, check "Time", select "Array" for "format". Run the simulation, check the value of "tout". How many data points do you have for "tout"?
Wei Yang Shen
2020-11-30
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
2020-12-1
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
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Manual Performance Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!