Description

Use ss to create state-space models (ss model
objects) with real- or complex-valued matrices or to convert dynamic
system models to state-space model form. You can also use ss to
create Generalized state-space (genss)
models.

Note:
Conversions to state space are not uniquely defined in the SISO
case. They are also not guaranteed to produce a minimal realization
in the MIMO case. For more information, see Recommended Working Representation.

Conversion of Identified Models

An identified model is represented by an input-output equation
of the form y(t) = Gu(t) + He(t),
where u(t) is the set of measured input channels
and e(t) represents the noise channels. If
Λ = LL' represents the covariance of noise e(t),
this equation can also be written as y(t) = Gu(t) + HLv(t),
where cov(v(t)) = I.

sys_ss = ss(sys) or sys_ss = ss(sys,
'measured') converts the measured component of an identified
linear model into the state-space form. sys is
a model of type idss, idproc, idtf, idpoly,
or idgrey. sys_ss represents
the relationship between u and y.

sys_ss = ss(sys, 'noise') converts the
noise component of an identified linear model into the state space
form. It represents the relationship between the noise input v(t) and
output y_noise = HL v(t). The noise input channels
belong to the InputGroup 'Noise'. The names of
the noise input channels are v@yname, where yname is
the name of the corresponding output channel. sys_ss has
as many inputs as outputs.

sys_ss = ss(sys, 'augmented') converts
both the measured and noise dynamics into a state-space model. sys_ss has ny+nu inputs
such that the first nu inputs represent the channels u(t) while
the remaining by channels represent the noise channels v(t). sys_ss.InputGroup contains
2 input groups- 'measured' and 'noise'.
sys_ss.InputGroup.Measured is set to 1:nu while sys_ss.InputGroup.Noise is
set to nu+1:nu+ny. sys_ss represents
the equation y(t) = [G HL] [u; v]

Tip
An identified nonlinear model cannot be converted into a state-space
form. Use linear approximation functions such as linearize and linapp.

Properties

A — State matrix A.
Square real- or complex-valued matrix with as many rows as states.

B — Input-to-state matrix B.
Real- or complex-valued matrix with as many rows as states and as
many columns as inputs.

C — State-to-output matrix C.
Real- or complex-valued matrix with as many rows as outputs and as
many columns as states.

D — Feedthrough matrix D.
Real- or complex-valued matrix with as many rows as outputs and as
many columns as inputs.

E — E matrix
for implicit (descriptor) state-space models. By default e
= [], meaning that the state equation is explicit. To specify
an implicit state equation Edx/dt = Ax + Bu,
set this property to a square matrix of the same size as A.
See dss for more information
about creating descriptor state-space models.

Scaled

Logical value indicating whether scaling is enabled or disabled.

When Scaled = 0 (false), most numerical algorithms
acting on the state-space model automatically rescale the state vector
to improve numerical accuracy. You can disable such auto-scaling
by setting Scaled = 1 (true). For more information
about scaling, see prescale.

Default: 0 (false)

StateName

State names, specified as one of the following:

Character vector — For first-order models,
for example, 'velocity'.

Cell array of character vectors — For models
with two or more states

'' — For unnamed states.

Default: '' for all states

StateUnit

State units, specified as one of the following:

Character vector — For first-order models,
for example, 'velocity'.

Cell array of character vectors — For models
with two or more states

'' — For unnamed states.

Use StateUnit to keep track of the units
each state is expressed in. StateUnit has no effect
on system behavior.

Default: '' for all states

InternalDelay

Vector storing internal delays.

Internal delays arise, for example, when closing feedback loops
on systems with delays, or when connecting delayed systems in series
or parallel. For more information about internal delays, see Closing Feedback Loops with Time Delays in the Control System Toolbox™ User's
Guide.

For continuous-time models, internal delays are expressed in
the time unit specified by the TimeUnit property
of the model. For discrete-time models, internal delays are expressed
as integer multiples of the sample time Ts. For
example, InternalDelay = 3 means a delay of three
sampling periods.

You can modify the values of internal delays. However, the
number of entries in sys.InternalDelay cannot change,
because it is a structural property of the model.

InputDelay

Input delay for each input channel, specified as a scalar value
or numeric vector. For continuous-time systems, specify input delays
in the time unit stored in the TimeUnit property.
For discrete-time systems, specify input delays in integer multiples
of the sample time Ts. For example, InputDelay
= 3 means a delay of three sample times.

For a system with Nu inputs, set InputDelay to
an Nu-by-1 vector. Each entry of this vector is
a numerical value that represents the input delay for the corresponding
input channel.

You can also set InputDelay to a scalar value
to apply the same delay to all channels.

Default: 0

OutputDelay

Output delays. OutputDelay is a numeric vector
specifying a time delay for each output channel. For continuous-time
systems, specify output delays in the time unit stored in the TimeUnit property.
For discrete-time systems, specify output delays in integer multiples
of the sample time Ts. For example, OutputDelay
= 3 means a delay of three sampling periods.

For a system with Ny outputs, set OutputDelay to
an Ny-by-1 vector, where each entry is a numerical
value representing the output delay for the corresponding output channel.
You can also set OutputDelay to a scalar value
to apply the same delay to all channels.

Default: 0 for all output channels

Ts

Sample time. For continuous-time models, Ts = 0.
For discrete-time models, Ts is a positive scalar
representing the sampling period. This value is expressed in the unit
specified by the TimeUnit property of the model.
To denote a discrete-time model with unspecified sample time, set Ts
= -1.

Changing this property does not discretize or resample the model.
Use c2d and d2c to convert between
continuous- and discrete-time representations. Use d2d to change the
sample time of a discrete-time system.

Default: 0 (continuous time)

TimeUnit

Units for the time variable, the sample time Ts,
and any time delays in the model, specified as one of the following
values:

'nanoseconds'

'microseconds'

'milliseconds'

'seconds'

'minutes'

'hours'

'days'

'weeks'

'months'

'years'

Changing this property has no effect on other properties, and
therefore changes the overall system behavior. Use chgTimeUnit to convert between time
units without modifying system behavior.

Default: 'seconds'

InputName

Input channel names, specified as one of the following:

Character vector — For single-input models,
for example, 'controls'.

Cell array of character vectors — For multi-input
models.

Alternatively, use automatic vector expansion to assign input
names for multi-input models. For example, if sys is
a two-input model, enter:

You can use the shorthand notation u to refer
to the InputName property. For example, sys.u is
equivalent to sys.InputName.

Input channel names have several uses, including:

Identifying channels on model display and plots

Extracting subsystems of MIMO systems

Specifying connection points when interconnecting
models

Default: '' for all input channels

InputUnit

Input channel units, specified as one of the following:

Character vector — For single-input models,
for example, 'seconds'.

Cell array of character vectors — For multi-input
models.

Use InputUnit to keep track of input signal
units. InputUnit has no effect on system behavior.

Default: '' for all input channels

InputGroup

Input channel groups. The InputGroup property
lets you assign the input channels of MIMO systems into groups and
refer to each group by name. Specify input groups as a structure.
In this structure, field names are the group names, and field values
are the input channels belonging to each group. For example:

sys.InputGroup.controls = [1 2];
sys.InputGroup.noise = [3 5];

creates input groups named controls and noise that
include input channels 1, 2 and 3, 5, respectively. You can then extract
the subsystem from the controls inputs to all outputs
using:

sys(:,'controls')

Default: Struct with no fields

OutputName

Output channel names, specified as one of the following:

Character vector — For single-output models.
For example, 'measurements'.

Cell array of character vectors — For multi-output
models.

Alternatively, use automatic vector expansion to assign output
names for multi-output models. For example, if sys is
a two-output model, enter:

You can use the shorthand notation y to refer
to the OutputName property. For example, sys.y is
equivalent to sys.OutputName.

Output channel names have several uses, including:

Identifying channels on model display and plots

Extracting subsystems of MIMO systems

Specifying connection points when interconnecting
models

Default: '' for all output channels

OutputUnit

Output channel units, specified as one of the following:

Character vector — For single-output models.
For example, 'seconds'.

Cell array of character vectors — For multi-output
models.

Use OutputUnit to keep track of output signal
units. OutputUnit has no effect on system behavior.

Default: '' for all output channels

OutputGroup

Output channel groups. The OutputGroup property
lets you assign the output channels of MIMO systems into groups and
refer to each group by name. Specify output groups as a structure.
In this structure, field names are the group names, and field values
are the output channels belonging to each group. For example:

creates output groups named temperature and measurement that
include output channels 1, and 3, 5, respectively. You can then extract
the subsystem from all inputs to the measurement outputs
using:

sys('measurement',:)

Default: Struct with no fields

Name

System name, specified as a character vector. For example, 'system_1'.

Default: ''

Notes

Any text that you want to associate with the system, specified
as a character vector or cell array of character vectors. For example, 'System
is MIMO'.

Default: {}

UserData

Any type of data you want to associate with system, specified
as any MATLAB® data type.

Default: []

SamplingGrid

Sampling grid for model arrays, specified as a data structure.

For model arrays that are derived
by sampling one or more independent variables, this property tracks
the variable values associated with each model in the array. This
information appears when you display or plot the model array. Use
this information to trace results back to the independent variables.

Set the field names of the data structure to the names of the
sampling variables. Set the field values to the sampled variable values
associated with each model in the array. All sampling variables should
be numeric and scalar valued, and all arrays of sampled values should
match the dimensions of the model array.

For example, suppose you create a 11-by-1
array of linear models, sysarr, by taking snapshots
of a linear time-varying system at times t = 0:10.
The following code stores the time samples with the linear models.

sysarr.SamplingGrid = struct('time',0:10)

Similarly, suppose you create a 6-by-9
model array, M, by independently sampling two variables, zeta and w.
The following code attaches the (zeta,w) values
to M.

For model arrays generated by linearizing a Simulink® model
at multiple parameter values or operating points, the software populates SamplingGrid automatically
with the variable values that correspond to each entry in the array.
For example, the Simulink Control Design™ commands linearize and slLinearizer populate SamplingGrid in
this way.

Default: []

Examples

Create Discrete-Time State-Space Model

Create a state-space model with a sample time of 0.25 seconds and the following state-space matrices:

The number of state and input names must be consistent with the dimensions of A, B, C, and D.

Convert Transfer Function to State-Space Model

Compute the state-space model of the following transfer function:

Create the transfer function model.

H = [tf([1 1],[1 3 3 2]) ; tf([1 0 3],[1 1 1])];

Convert this model to a state-space model.

sys = ss(H);

Examine the size of the state-space model.

size(sys)

State-space model with 2 outputs, 1 inputs, and 5 states.

The number of states is equal to the cumulative order of the SISO entries in H(s).

To obtain a minimal realization of H(s), enter

sys = ss(H,'minimal');
size(sys)

State-space model with 2 outputs, 1 inputs, and 3 states.

The resulting model has an order of three, which is the minimum number of states needed to represent H(s). To see this number of states, refactor H(s) as the product of a first-order system and a second-order system.

sys =
Generalized continuous-time state-space model with 1 outputs, 1 inputs, 2 states, and the following blocks:
a: Scalar parameter, 2 occurrences.
b: Scalar parameter, 2 occurrences.
Type "ss(sys)" to see the current value, "get(sys)" to see all properties, and "sys.Blocks" to interact with the blocks.

sys is a generalized LTI model (genss) with tunable parameters a and b.

Extract Components from Identified State-Space Model

Extract the measured and noise components of an identified polynomial
model into two separate state-space models. The former (measured component)
can serve as a plant model while the latter can serve as a disturbance
model for control system design.

More About

Algorithms

For TF to SS model conversion, ss(sys_tf) returns
a modified version of the controllable canonical form. It uses an
algorithm similar to tf2ss, but further rescales
the state vector to compress the numerical range in state matrix A and
to improve numerics in subsequent computations.

For ZPK to SS conversion, ss(sys_zpk) uses
direct form II structures, as defined in signal processing texts.
See Discrete-Time Signal Processing by Oppenheim
and Schafer for details.

For example, in the following code, A and sys.A differ
by a diagonal state transformation: