| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |
Simulink allows you to specify the initial values of signals and discrete states, i.e., the values of the signals and discrete states at the Start time of the simulation. You can use signal objects to specify the initial values of any signal or discrete state in a model. In addition, for some blocks, e.g., Outport, Data Store Memory, or Memory, you can use either a signal object or a block parameter or both to specify the initial value of a block state or output. In such cases, Simulink checks to ensure that the values specified by the signal object and the parameter are consistent.
When you specify a signal object for signal or discrete state initialization, or a variable as the value of a block parameter, Simulink resolves the name that you specify to an appropriate object or variable, as described in Resolving Symbols.
A given signal can be associated with at most one signal object under any circumstances. The signal can refer to the object more that once, but every reference must resolve to exactly the same object. A different signal object that has exactly the same properties will not meet the requirement for uniqueness. A compile-time error occurs if a model associates more than one signal object with any signal. For more information, see Simulink.Signal and the Merge block.
For blocks that have an initial value or initial condition parameter, you can use that parameter to initialize a signal. For example, the following Block Parameters dialog box initializes the signal for a Unit Delay block with an initial condition of 0.5.

To use a signal object to specify an initial value:
Create the signal object in the MATLAB workspace, as explained in Working with Data Objects.
The name of the signal object must be the same as the name of the signal or discrete state that the object is initializing.
Set the signal object's storage class to a value other than 'Auto' or 'SimulinkGlobal'.
Set the signal object's Initial value property to the initial value of the signal or state. For details on what you can specify, see the description of Simulink.Signal.
If you can also use a block parameter to set the initial value of the signal or state, you should set the parameter either to null ([]) or to the same value as the initial value of the signal object. If you set the parameter value to null, Simulink uses the value specified by the signal object to initialize the signal or state. If you set the parameter to any other value, Simulink compares the parameter value to the signal object value and displays an error if they differ.
Simulink allows you to use signal objects as an alternative to parameter objects (see Simulink.Parameter ) to tune the initial values of block outputs and states that can be specified via a tunable parameter. To use a signal object to tune an initial value, create a signal object with the same name as the signal or state and set the signal object's initial value to an expression that includes a variable defined in the MATLAB workspace. You can then tune the initial value by changing the value of the corresponding workspace variable during the simulation.
For example, suppose you want to tune the initial value of a Memory block state named M1. To do this, you might create a signal object named M1, set its storage class to 'ExportedGlobal', set its initial value to K (M1.InitialValue='K'), where K is a workspace variable in the MATLAB workspace, and set the corresponding initial condition parameter of the Memory block to [] to avoid consistency errors. You could then change the initial value of the Memory block's state any time during the simulation by changing the value of K at the MATLAB command line and updating the block diagram (e.g., by typing Ctrl+D).
Note To be tunable via a signal object, a signal or state's corresponding initial condition parameter must be tunable, e.g., the inline parameter optimization for the model containing the signal or state must be off or the parameter must be declared tunable in the Model Parameter Configuration dialog box. For more information, see Tunable Parameters and Changing the Values of Block Parameters During Simulation. |
The following example shows a signal object specifying the initial output of an enabled subsystem.

Signal s is initialized to 4.5. To avoid a consistency error, the initial value of the enabled subsystem's Outport block must be [] or 4.5.
If you need a signal object and its initial value setting to persist across Simulink sessions, see Creating Persistent Data Objects.
The following model and table show different types of signals and discrete states that you can initialize and the simulation behavior that results for each.

| Signal or Discrete State | Description | Behavior |
|---|---|---|
| S1 | Root inport |
|
| X1 | Unit Delay block — Block with a discrete state that has an initial condition |
|
| X2 | Data Store Memory block |
|
| S2 | Output of an enabled subsystem |
|
| S3 | Persistent signals |
|
![]() | The Signal Selector | Working with Test Points | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |