How do I get the minor time in a MATLAB s-function?
조회 수: 7 (최근 30일)
이전 댓글 표시
Inside a Level-2 Matlab S-function, block.CurrentTime gives the value of the major time. How can we get the value of the minor time?
댓글 수: 0
채택된 답변
Kaustubha Govind
2011년 5월 26일
Actually, block.CurrentTime gives the value of the current time-step in the simulation (could be either major or minor). The block outputs and derivatives (and potentially, zero-crossings) methods are run in minor time-steps. So if you are querying block.CurrentTime in one of these functions, you should simply have to check block.IsMajorTimeStep to verify if you're in a major/minor time-step.
댓글 수: 1
추가 답변 (2개)
Guy Rouleau
2011년 5월 27일
I recommend looking at this submission:
It contains a level-2 MATLAB s-function which reads and separate values from major and minor steps.
I use the files in this submission often to better understand continuous solver behavior. Just for my curiosity, can you provide more details on why you want to access minor time steps data?
댓글 수: 2
trantoan
2018년 4월 20일
Hi manav, I wonder if you could share your solution strategy. At the present, I have a similar issue. Hope to hear your recommendation. Best, Toan
tianyuan wang
2023년 3월 9일
I encountered a similar problem.
If I choose the ode4 solver, does the model loop four times in one time step?
Another question is, if I use S-function in my model and call S-function once in a time step, how does ode4 extrapolate the results of S-functions? Does the result of the S-function have to be a function of time t? Or Simulink automatically extrapolate based on the value of S-function?
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Simulink Functions에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!