How can I initialize internal variable of s-function every simulation?

조회 수: 18 (최근 30일)
Hello :D
I'm having a problem with s-function.
I'd like to initialize all value of s-function, but I can't.
I think the last value of internal variable is not initialized when I execute simulation again.
So, before execute simulation, I'd like to initialize internal state of s-function.
I'm wating for your answers.
Thank you.

채택된 답변

Mark McBroom
Mark McBroom 2020년 3월 22일
Add code to the mdlStart() or mdlInitialize() functions in the SFunctionto reset state variables.
  댓글 수: 2
DongWook Shin
DongWook Shin 2020년 3월 23일
Thanks to your advice, I was able to implement what I want.
Is there any method to reset state variables at once?
Ani Singh
Ani Singh 2020년 3월 24일
Put your S-function inside an enabled subsystem with "Output when disabled" set to "reset" - this will call your mdlInitializeConditions method every time the subsystem is disabled.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Block and Blockset Authoring에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by