matlabsimulinkstateflow

Matlab stateflow else transition


I have a Stateflow with state that handles the following pseudo code:

if input1==1 then
  new_state=state2;
else if input==2 then
  new_state=state3;
else
  new_state=error_state;
end if;

How to model the else in Stateflow? Currently I'm using [~(input==1 || input==2)], but when I have 10 transitions it becomes very nasty.


Solution

  • You want the following type of construct. From state_one the decision about where to move next is made successively at each junction.

    enter image description here