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

2 visualizaciones (últimos 30 días)
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.

Respuestas (1)

Yifeng Tang
Yifeng Tang el 6 de Mayo de 2021
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

Categorías

Más información sobre Troubleshooting en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by