How to get the instantaneous step size value in variable step solver at a simulink model?

2 ビュー (過去 30 日間)
Omer Utku Altindag
Omer Utku Altindag 2021 年 5 月 4 日
回答済み: Yifeng Tang 2021 年 5 月 6 日
I got a problem to get the value of instantaneous step size value in variable step solver. In my simscape model there is also a runge kutta solver function that I wrote and I need a h value which is a h=step_value/10. I dont want to use fixed step solver. That is why I need to know step value for each time step.

回答 (1 件)

Yifeng Tang
Yifeng Tang 2021 年 5 月 6 日
If you turn on data logging for Simscape, you can access the time marks in the states data for each block. Any block will give you the same time array. More details here: https://www.mathworks.com/help/physmod/simscape/ug/log-and-plot-simulation-data.html
The time information should also be available in Simulink tout variable, depending on your model settings.
One example:
ssc_mass_spring_damper_sl; % open a simple Simscape example
Run the model. Then in the results:
time = simlog_ssc_mass_spring_damper_sl.Spring.x.series.time; % time
X = simlog_ssc_mass_spring_damper_sl.Spring.x.series.values('cm'); % displacement in specified unit
time2 = tout; % same time info
If you want to see which block is limiting the time steps, try the Solver Profiler: https://www.mathworks.com/help/simulink/ug/examine-solver-behavior-using-solver-profiler.html

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by