How to return the index of time steps in Simulink?

조회 수: 20 (최근 30일)
Ammar S.
Ammar S. 2020년 10월 27일
답변: Jim Riggs 2020년 10월 28일
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
Paul
Paul 2020년 10월 28일
Do you want to do this after the sim is complete or while the sim is running?

댓글을 달려면 로그인하십시오.

답변 (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