Borrar filtros
Borrar filtros

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 visualización (últimos 30 días)
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.

Respuestas (1)

Will Nitsch
Will Nitsch el 3 de Mayo de 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;

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by