Declare operating modes in mode chart
Parent Section: modecharts
modes mode m1 ... end end
modes begins a modes declaration section in a mode chart. The
modes section, terminated by an
can contain one or more
mode constructs. Each
construct declares one mode.
For example, the following syntax declares two modes,
modes mode m1 ... end mode m2 ... end end
mode is a named construct. It is terminated by an
end keyword. Each mode declaration contains a complete set of
equations that describe this operating mode.
modes mode m1 equations ... end end mode m2 equations ... end end end
For every mode, the total number of equation expressions, their dimensionality, and
their order must be the same. This restriction is the same as for the equations in
different branches of the
This restriction does not apply to the
assert expressions, because
they are not included in the expression count.
A mode declaration can contain an
which lets you specify the actions to be performed upon entering the mode. These actions
are event variable updates based on the value of a continuous variable immediately
before entering the mode.
modes mode m1 equations ... end end mode m2 entry ... end equations ... end end end
entry section is separate from the
equations section, and the event variable
updates in the
entry section are not counted in the
number of equation expressions for the mode.
To implement a state reset, mode charts can contain instantaneous modes and compound transitions. An instantaneous mode is a mode that is active only for one event iteration. You declare instantaneous modes the same way as regular modes, using the same syntax. The same mode can be used as an instantaneous mode in one case and a regular mode in another, depending on the transitions declared in a mode chart. To specify that a mode is instantaneous, list it as the middle mode in a compound transition.
For a detailed example of using
modes, see Switch with Hysteresis.
Introduced in R2017a