Documentation

initial

Specify initial mode in mode chart

Syntax

initial init_mode : predicate_condition end     

Description

initial begins the initial mode construct in a mode chart. The construct is terminated by an end keyword. It contains one statement with the following syntax:

init_mode : predicate_condition

where:

  • init_mode is the mode active at the start of simulation if the expression in the predicate_condition is true.

  • If predicate_condition is false, then the first mode listed in the modes section is active at the start of simulation.

The predicate_condition must be a parametric expression because it is evaluated at compile time. Using a variable in a predicate results in a compile-time error.

The initial construct is optional. If a mode chart does not contain an initial construct, then the first mode listed in the modes section is active at the start of simulation.

For example, a mode chart declares three modes, m1, m2, and m3:

modes
    mode m1
    ...
    end
    mode m2
    ...
    end
    mode m3
    ...
    end
end

By default, mode m1 is active at the start of simulation. If you include the following initial construct:

initial
    m2 : p1
end

then, if the p1 predicate is true, simulation starts in mode m2; otherwise, in mode m1.

The initial construct can have multiple initial mode statements, for example:

initial
    m2 : p1
    m3 : p2
end

In this case:

  • If the p1 predicate is true, simulation starts in mode m2.

  • If the p2 predicate is true, simulation starts in mode m3.

  • If both predicates are true, simulation starts in mode m2 (the first one listed in the initial section).

  • If both predicates are false, simulation starts in mode m1 (the first one listed in the modes section).

Introduced in R2017a

Was this topic helpful?