Filter löschen
Filter löschen

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 Ansicht (letzte 30 Tage)
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.

Antworten (1)

Will Nitsch
Will Nitsch am 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;

Kategorien

Mehr zu Simulink Functions finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by