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

18 vues (au cours des 30 derniers jours)
DongWook Shin
DongWook Shin le 17 Mar 2020
Commenté : Ani Singh le 24 Mar 2020
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.

Réponse acceptée

Mark McBroom
Mark McBroom le 22 Mar 2020
Add code to the mdlStart() or mdlInitialize() functions in the SFunctionto reset state variables.
  2 commentaires
DongWook Shin
DongWook Shin le 23 Mar 2020
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 le 24 Mar 2020
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Block and Blockset Authoring dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by