How to return the index of time steps in Simulink?

17 Ansichten (letzte 30 Tage)
Ammar S.
Ammar S. am 27 Okt. 2020
Beantwortet: Jim Riggs am 28 Okt. 2020
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 Kommentar
Paul
Paul am 28 Okt. 2020
Do you want to do this after the sim is complete or while the sim is running?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jim Riggs
Jim Riggs am 28 Okt. 2020
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.

Kategorien

Mehr zu General Applications finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by