Discrete State-Space

Implement discrete state-space system




Block Behavior for Non-Empty Matrices

The Discrete State-Space block implements the system described by


where u is the input, x is the state, and y is the output. The matrix coefficients must have these characteristics, as illustrated in the following diagram:

  • A must be an n-by-n matrix, where n is the number of states.

  • B must be an n-by-m matrix, where m is the number of inputs.

  • C must be an r-by-n matrix, where r is the number of outputs.

  • D must be an r-by-m matrix.

The block accepts one input and generates one output. The width of the input vector is the number of columns in the B and D matrices. The width of the output vector is the number of rows in the C and D matrices. To define the initial state vector, use the Initial conditions parameter.

To specify a vector or matrix of zeros for A, B, C, D, or Initial conditions, use the zeros function.

Block Behavior for Empty Matrices

When the matrices A, B, and C are empty (for example, []), the functionality of the block becomes y(n) = Du(n). If the Initial conditions vector is also empty, the block uses an initial state vector of zeros.

Data Type Support

The Discrete State Space block accepts and outputs a real signal of type single or double. For more information, see Data Types Supported by Simulink in the Simulink® documentation.

Parameters and Dialog Box

A, B, C, D

Specify the matrix coefficients, as defined in the Description section.

Initial conditions

Specify the initial state vector. The default value is 0. Simulink does not allow the initial states of this block to be inf or NaN.

Sample time (–1 for inherited)

Specify the time interval between samples. See Specify Sample Time.

State name

Use this parameter to assign a unique name to the block state. The default is ' '. When this field is blank, no name is assigned. When using this parameter, remember these considerations:

  • A valid identifier starts with an alphabetic or underscore character, followed by alphanumeric or underscore characters.

  • The state name applies only to the selected block.

This parameter enables State name must resolve to Simulink signal object when you click Apply.

For more information, see Discrete Block State Naming in Generated Code in the Simulink Coder™ documentation.

State name must resolve to Simulink signal object

Select this check box to require that the state name resolve to a Simulink signal object. This check box is cleared by default.

State name enables this parameter.

Selecting this check box disables Code generation storage class.

Signal object class

Choose a custom storage class package by selecting a signal object class that the target package defines. For example, to apply custom storage classes from the built-in package mpt, select mpt.Signal. Unless you use an ERT-based code generation target with Embedded Coder® software, custom storage classes do not affect the generated code.

If the class that you want does not appear in the list, select Customize class lists. For instructions, see Apply Custom Storage Classes Directly to Signal Lines and Block States.

Code generation storage class

Select state storage class for code generation.

Default: Auto


Auto is the appropriate storage class for states that you do not need to interface to external code.


Applies the storage class or custom storage class that you select from the list. For information about storage classes, see Control Signals and States in Code by Applying Storage Classes. For information about custom storage classes, see Control Data Representation by Applying Custom Storage Classes.

Use Signal object class to select custom storage classes from a package other than Simulink.

State name enables this parameter.


    Note:   TypeQualifier will be removed in a future release. To apply storage type qualifiers to data, use custom storage classes and memory sections. Unless you use an ERT-based code generation target with Embedded Coder software, custom storage classes and memory sections do not affect the generated code.

Specify a storage type qualifier such as const or volatile.

Setting Code generation storage class to ExportedGlobal, ImportedExtern, ImportedExternPointer, or SimulinkGlobal enables this parameter. This parameter is hidden unless you previously set its value.

During simulation, the block uses the following values:

  • The initial value of the signal object to which the state name is resolved

  • Min and Max values of the signal object

For more information, see Discrete Block State Naming in Generated Code in the Simulink Coder documentation.


Data Types

Double | Single

Sample Time

Specified in the Sample time parameter

Direct Feedthrough

Only if D ≠ 0

Multidimensional Signals


Variable-Size Signals


Zero-Crossing Detection


Code Generation


Introduced before R2006a

Was this topic helpful?