In State flow, consider state 1 and state 2 with transitions between them. if there are 2 actions in state 1, is there a way to execute action 1 only the first time state 1 is entered ? during re-entry to state 1, only action 2 should be executed

1 vue (au cours des 30 derniers jours)
In State flow, consider state 1 and state 2 with transitions between them. if there are 2 actions in state 1, is there a way to execute action 1 only the first time state 1 is entered ? during re-entry to state 1, only action 2 should be executed and I am using the data from action 1 in sub-states. entry: command would execute the action every time a particular state is entered.

Réponses (1)

Will Nitsch
Will Nitsch le 3 Mai 2017
You could create some variable and set it equal to 0 (say 'a = 0') in the initialization code, and then, in the entry function of the block have an if else statement like so:
entry:
if(~a)
doFunction1(some arguments);
a = 1;
else
doFunction2(some other arguments);
end
during:
doFunction3(even more arguments);
bind: a;

Catégories

En savoir plus sur Simulink Functions 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