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 回表示 (過去 30 日間)
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.

回答 (1 件)

Will Nitsch
Will Nitsch 2017 年 5 月 3 日
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;

カテゴリ

Help Center および File ExchangeSimulink Functions についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by