Hauptinhalt

State-Space

Model continuous linear system as system of explicit state-space equations

  • State-Space block

Libraries:
Simulink / Continuous

Description

The State-Space block models a linear system as a system of ordinary differential equations expressed in the explicit form:

x˙=Ax+Buy=Cx+Dux|t=t0=x0,

where:

  • x is the state vector.

  • u is the input vector.

  • y is the output vector.

  • x0 is the initial condition of the system, which provides the initial value of the state vector.

  • A, B, C, and D are matrices that contain the coefficients of the terms in the system equations.

You can use the State-Space block to model both time invariant and time variant linear implicit systems.

  • To model time invariant systems, specify the A, B, C, and D parameters as constant matrices.

  • To model time variant systems, tune the A, B, C, and D parameters during simulation.

To model continuous linear implicit systems, use the Descriptor State-Space block.

Specify System Matrices

To model your system, specify the system matrices using the A, B, C, and D parameters. You can specify either sparse or full matrices. By default, MATLAB® creates full matrices. For more information, see Constructing Sparse Matrices.

  • To convert a full matrix to a sparse matrix, use the sparse function.

  • To convert a sparse matrix to a full matrix, use the full function.

  • To determine whether a matrix is sparse, use the issparse function.

The number of states, inputs, and outputs in the system determine the dimensions of the system matrices.

  • An-by-n, where n is the number of states in the system.

  • Bn-by-m, where:

    • n is the number of states in the system.

    • m is the number of system inputs.

  • Cr-by-n, where:

    • r is the number of system outputs.

    • n is the number of states in the system.

  • Dr-by-m, where:

    • r is the number of system outputs.

    • m is the number of system inputs.

The image shows how the dimensions of the system matrices relate to each other.

Diagram of system matrices arranged such that common dimensions are adjacent.

Examples

expand all

Autonomous linear systems have no inputs. When you implement an autonomous linear system, the block acts as a source block.

To model an autonomous linear system, specify the B and D parameters as empty matrices.

The block implements a system with equations that have this form:

x˙=Axy=Cxx|t=t0=x0.

Extended Examples

Ports

Input

expand all

Input values must be real. The dimensions of the input signal must match the number of system inputs.

  • When the system has one input, connect a scalar signal.

  • When the system has multiple inputs, connect a vector signal that contains an element for each system input.

Dependencies

This port has direct feedthrough when:

  • You set the Direct Feedthrough parameter to True.

  • You set the Direct Feedthrough parameter to Auto and the software determines that the block has direct feedthrough.

Data Types: double

Output

expand all

The dimensions of the output signal match the number of system outputs.

  • When the system has one output, the block produces a scalar signal.

  • When the system has multiple outputs, the block produces a vector signal that contains an element for each system output.

Data Types: double

Parameters

expand all

Specify a matrix that:

  • Contains only real values.

  • Has dimensions n-by-n, where n is the number of states in the system.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

To get the block parameter value programmatically, use the get_param function.

Parameter: A
Values: '1' (default) | scalar | vector | matrix
Data Types: string | char

Example: set_param("MyModel/State-Space",A="[1 2;3 4]")

Specify a matrix that:

  • Contains only real values.

  • Has dimensions n-by-m, where n is the number of states in the system, and m is the number of system inputs.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

To get the block parameter value programmatically, use the get_param function.

Parameter: B
Values: '1' (default) | scalar | vector | matrix
Data Types: string | char

Example: set_param("MyModel/State-Space",B="[1 2]")

Specify a matrix that:

  • Contains only real values.

  • Has dimensions r-by-n, where r is the number of system outputs, and n is the number of states in the system.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

To get the block parameter value programmatically, use the get_param function.

Parameter: C
Values: '1' (default) | scalar | vector | matrix
Data Types: string | char

Example: set_param("MyModel/State-Space",C="[3 4]")

Specify a matrix that:

  • Contains only real values.

  • Has dimensions r-by-m, where r is the number of system outputs, and m is the number of system inputs.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

To get the block parameter value programmatically, use the get_param function.

Parameter: D
Values: '1' (default) | scalar | vector | matrix
Data Types: string | char

Example: set_param("MyModel/State-Space",D="5")

To initialize the system, specify the initial values of states in the system. States cannot have Inf or NaN values.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

To get the block parameter value programmatically, use the get_param function.

Parameter: InitialCondition
Values: '0' (default) | scalar | vector | matrix
Data Types: string | char

Example: set_param("MyModel/Descriptor State-Space",InitialCondition="[2 3]")

Alternatively, use X0.

To model time variant systems, you can tune the system matrix parameters during simulation. This parameter specifies how the software represents the system matrix parameters in the compiled model or the simulation target for accelerator and rapid accelerator simulations.

  • Auto — The software determines how to represent tunable parameters by analyzing the system matrices.

  • Optimized — The software optimizes the parameter representation for simulation execution.

    This option improves performance but places additional restrictions on the values you can specify when you tune the parameters during simulation.

  • Unconstrained — The software does not optimize the parameter representation for simulation execution.

    This option places the fewest restrictions on the values you can specify when you tune the parameters during simulation.

The values you can specify when you tune the system matrix parameters depend on the value of this parameter and whether the initial value of the system matrix is specified as a sparse or full matrix.

Initial Matrix Parameter ValueOptimized Parameter TunabilityUnconstrained Parameter Tunability
Sparse matrix

Matrix pattern is fixed. Only elements with nonzero values in the initial matrix are tunable.

The matrix pattern can change, but the number of nonzero elements in the matrix cannot increase.

Full matrix

The matrix pattern can change, but the number of nonzero elements in the matrix cannot increase.

All elements of the matrix can change.

Dependencies

To tune the D parameter during simulation when the initial parameter value is 0, enable Allow non-zero values for D matrix initially specified as zero.

To tune the system matrices using the Parameter Writer block, specify the parameters as full matrices.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

To get the block parameter value programmatically, use the get_param function.

Parameter: ParameterTunability
Values: 'Auto' (default) | "Optimized" | "Unconstrained"

Example: set_param("MyModel/State-Space",ParameterTunability="Optimized")

By default, you cannot tune the D parameter during simulation if the initial value is 0. Select this parameter to enable tuning the D parameter during simulation when the initial value is 0.

Dependencies

When you enable this parameter, the block has direct feedthrough.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

To get the block parameter value programmatically, use the get_param function.

Parameter: AllowTunableDMatrix
Values: 'off' (default) | "on"

Example: set_param("MyModel/State-Space",AllowTunableMatrix="Optimized")

Variable-step solvers use absolute and relative tolerances to determine whether the error in state calculations is acceptable when choosing the step size. This parameter specifies the absolute tolerance to use for states in the system implemented by this block.

  • auto — Use the absolute tolerance specified by the Absolute tolerance configuration parameter.

  • Real, positive, scalar — Use the specified value as the absolute tolerance for all states.

  • Real, positive vector — Specify an absolute tolerance for each state. The number of elements in the vector must be the same as the number of states in the system.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

To get the block parameter value programmatically, use the get_param function.

Parameter: AbsoluteTolerance
Values: 'auto' (default) | "-1" | positive real scalar | positive real vector
Data Types: string | char

Example: set_param("MyModel/Descriptor State-Space",AbsoluteTolerance="-1")

If you do not specify a custom name for every state in the system:

  • Each specified name is used for more than one state.

  • The number of states must be evenly divisible by the number of specified names.

For example, if the system has four states, you must specify one, two, or four names. If you specify two names, the first two states use the first name and the last two states use the second name.

To specify a single custom state name using the Property Inspector or the Block Parameters dialog box, include single quotes ('') around the name. For example, to specify the name position, enter 'position'. If you omit the single quotes, the software interprets the value as the name of a MATLAB variable.

To use default state names, specify this parameter as an empty character vector ('').

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

To get the block parameter value programmatically, use the get_param function.

Parameter: ContinuousStateAttributes
Values: '' (default)
Data Types: char | cell

Example: set_param("MyModel/Descriptor State-Space",ContinuousStateAttributes={'position','velocity'})

Block Characteristics

Data Types

double

Direct Feedthrough

yes

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

no

Extended Capabilities

expand all

Version History

Introduced before R2006a