Control Initial Value of Signals and States

When modeling dynamic systems, it is often necessary to control the initialization and reset characteristics of signals and states. This model shows how this can be done using the initial value property of signal objects.

Open Example Model

Open the example model rtwdemo_sigobj_iv.


In this model, the following signals and states are configured using signal objects:

  • Root input signal (S1)

  • Discrete states initial condition (X1, X2)

  • Conditionally executed subsystem output port initial output (S2)

  • Other persistent signals (S3)

The initial values of signal objects X1 and S2 are specified using tunable parameters aa1 and aa2 respectively.


  1. Simulate the model and inspect the results in the scope display.

  2. Generate code by double-clicking a blue button. Inspect the generated code.

  3. Change the initial value of X1 or S2 (or the tunable parameters aa1 or aa2) in the Model Explorer and redo the simulation and code generation to inspect the results.

Was this topic helpful?