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!