Main Content

entry

Specify actions to be performed upon entering a mode

Since R2020b

Syntax

entry v_old = v; end     

Description

The entry block, terminated by an end keyword, is an optional section inside a mode declaration that 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 expression immediately before entering the mode.

modes
    mode m
       entry
          v_old = v;
       end
       equations
       ...
       end
    end
end

The entry section is especially useful for modeling state reset because, in the majority of state reset use cases, the reset value is a function of the previous value of the variable. For example, when modeling a slider moving between two hard stops, the new velocity depends on the velocity before impact. For more information and an example, see State Reset Example.

In each entry action, the left-hand side must be an event variable. The right-hand side is a continuous expression, evaluated immediately before entering the mode. This expression can include any combination of continuous variables, event variables, and intermediates.

You can use entry actions both in instantaneous and regular modes.

Version History

Introduced in R2020b