How to set a fixed execution period of an M-Function in simulink?

조회 수: 4 (최근 30일)
Hi,
I'm using an M-function in simulink and checking the execution period of it I realized that is variable. It can vary from 100 us to 10 us more or less.
Is this because it's synchronized with the simulink step time? I am using a variable step time.
Is there any way to control this execution time without setting a fixed one in the simulink model? I want to execute a routine in the M-function with a fixed step time.
Thanks!

채택된 답변

Kaustubha Govind
Kaustubha Govind 2013년 2월 19일
No, AFAIK, the only way to ensure a fixed-step time for your model is to pick a Fixed-Step Solver and specify the desired step-time. Please read the documentation section Choose a Solver to understand how the variable-step solver chooses the next time step based on the dynamics of your model.
However, if you need a certain block only to run at the specific rate, you should be able to get that to work by specifying the block sample time. Not all blocks have this option though - which ones are you using?
  댓글 수: 1
Dani Tormo
Dani Tormo 2013년 2월 20일
The M-Function is the one which I want to execute at a certain frequency. I finally get this working using a pulse generator and reading this value before execute the subroutine.
Interesting this link about the solvers.
Many thanks Kaustubha!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Sources에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by