How to return the index of time steps in Simulink?

19 次查看(过去 30 天)
Hello,
I want to write a simulink function that returns the index of a specific current simulation time.
For example: let's say I have a total simulation time of 3000 I want a function when simulation time reaches 300 to tell me how many time steps have passed.

回答(1 个)

Jim Riggs
Jim Riggs 2020-10-28
One way to do this is to put a step counter in the block. This will keep track of the number of times the block is executed. This way, you get the right number of steps, even if the model is using a variable timestep.
When the simulation time reaches the desired value, output the value of the counter.

类别

Help CenterFile Exchange 中查找有关 General Applications 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by