Create statespace model, convert to statespace model
sys
= ss(A
,B
,C
,D
) sys
= ss(A
,B
,C
,D
,Ts
) sys
= ss(D
)sys
= ss
(A
,B
,C
,D
,ltisys
)
sys_ss = ss(sys) sys_ss
= ss(sys
,'minimal')sys_ss
= ss(sys
,'explicit')
sys_ss = ss(sys,
'measured')
sys_ss = ss(sys, 'noise')
sys_ss = ss(sys, 'augmented')
Use ss
to create statespace models (ss
model
objects) with real or complexvalued matrices or to convert dynamic
system models to statespace model form. You can also use ss
to
create Generalized statespace (genss
)
models.
creates
a statespace model object representing the continuoustime statespace
modelsys
= ss(A
,B
,C
,D
)
$$\begin{array}{l}\dot{x}=Ax+Bu\\ y=Cx+Du\end{array}$$
For a model with Nx
states, Ny
outputs,
and Nu
inputs:
A
is an Nx
byNx
real
or complexvalued matrix.
B
is an Nx
byNu
real
or complexvalued matrix.
C
is an Ny
byNx
real
or complexvalued matrix.
D
is an Ny
byNu
real
or complexvalued matrix.
To set D = 0
, set D
to
the scalar 0
(zero), regardless of the dimension.
creates the discretetime modelsys
= ss(A
,B
,C
,D
,Ts
)
$$\begin{array}{l}x[n+1]=Ax[n]+Bu[n]\\ y[n]=Cx[n]+Du[n]\end{array}$$
with sample time Ts
(in seconds). Set Ts
= 1
or Ts = []
to leave the sample time
unspecified.
specifies
a static gain matrix sys
= ss(D
)D
and is equivalent to
sys = ss([],[],[],D)
creates a statespace model with properties inherited from the model sys
= ss
(A
,B
,C
,D
,ltisys
) ltisys
(including
the sample time).
Any of the previous syntaxes can be followed by property name/property value pairs.
'PropertyName',PropertyValue
Each pair specifies a particular property of the model, for
example, the input names or some notes on the model history. See Properties for more information about
available ss
model object properties.
The following expression:
sys = ss(A,B,C,D,'Property1',Value1,...,'PropertyN',ValueN)
is equivalent to the sequence of commands:
sys = ss(A,B,C,D) set(sys,'Property1',Value1,...,'PropertyN',ValueN)
sys_ss = ss(sys)
converts
a dynamic system model sys
to statespace form.
The output sys_ss
is an equivalent statespace
model (ss
model object). This operation is known as statespace realization.
produces
a statespace realization with no uncontrollable or unobservable states.
This statespace realization is equivalent to sys_ss
= ss(sys
,'minimal')sys_ss = minreal(ss(sys))
.
computes
an explicit realization (sys_ss
= ss(sys
,'explicit')E
= I) of the dynamic
system model sys
. If sys
is
improper, ss
returns an error.
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. 
An identified model is represented by an inputoutput equation of the form $$\text{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 $$\text{y(t)=Gu(t)+HLv(t)}$$, where $$\text{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 statespace 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 statespace 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 $$\text{y(t)=[GHL][u;v]}$$
Tip
An identified nonlinear model cannot be converted into a statespace
form. Use linear approximation functions such as 
You can use the syntax:
gensys = ss(A,B,C,D)
to create a Generalized statespace (genss
)
model when one or more of the matrices A
, B
, C
, D
is
a tunable realp
or genmat
model. For more information about
Generalized statespace models, see Models with Tunable Coefficients.
ss
objects have the following properties:

Statespace matrices.


Logical value indicating whether scaling is enabled or disabled. When Default: 0 (false) 

State names, specified as one of the following:
Default: 

State units, specified as one of the following:
Use Default: 

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 continuoustime models, internal delays are expressed in
the time unit specified by the You can modify the values of internal delays. However, the
number of entries in 

Input delay for each input channel, specified as a scalar value
or numeric vector. For continuoustime systems, specify input delays
in the time unit stored in the For a system with You can also set Default: 0 

Output delays. For a system with Default: 0 for all output channels 

Sample time. For continuoustime models, Changing this property does not discretize or resample the model.
Use Default: 

Units for the time variable, the sample time
Changing this property has no effect on other properties, and
therefore changes the overall system behavior. Use Default: 

Input channel names, specified as one of the following:
Alternatively, use automatic vector expansion to assign input
names for multiinput models. For example, if sys.InputName = 'controls'; The input names automatically expand to You can use the shorthand notation Input channel names have several uses, including:
Default: 

Input channel units, specified as one of the following:
Use Default: 

Input channel groups. The sys.InputGroup.controls = [1 2]; sys.InputGroup.noise = [3 5]; creates input groups named sys(:,'controls') Default: Struct with no fields 

Output channel names, specified as one of the following:
Alternatively, use automatic vector expansion to assign output
names for multioutput models. For example, if sys.OutputName = 'measurements'; The output names automatically expand to You can use the shorthand notation Output channel names have several uses, including:
Default: 

Output channel units, specified as one of the following:
Use Default: 

Output channel groups. The sys.OutputGroup.temperature = [1]; sys.InputGroup.measurement = [3 5]; creates output groups named sys('measurement',:) Default: Struct with no fields 

System name, specified as a character vector. For example, Default: 

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

Any type of data you want to associate with system, specified as any MATLAB^{®} data type. Default: 

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 11by1
array of linear models, sysarr.SamplingGrid = struct('time',0:10) Similarly, suppose you create a 6by9
model array, [zeta,w] = ndgrid(<6 values of zeta>,<9 values of w>) M.SamplingGrid = struct('zeta',zeta,'w',w) When you display M M(:,:,1,1) [zeta=0.3, w=5] = 25  s^2 + 3 s + 25 M(:,:,2,1) [zeta=0.35, w=5] = 25  s^2 + 3.5 s + 25 ... For model arrays generated by linearizing a Simulink^{®} model
at multiple parameter values or operating points, the software populates Default: 
Create a statespace model with a sample time of 0.25 seconds and the following statespace matrices:
Specify the statespace matrices.
A = [0 1;5 2]; B = [0;3]; C = [0 1]; D = 0;
Specify the sample time.
Ts = 0.25;
Create the statespace model.
sys = ss(A,B,C,D,Ts);
Create statespace matrices and specify sample time.
A = [0 1;5 2]; B = [0;3]; C = [0 1]; D = 0; Ts = 0.05;
Create statespace model, specifying the state and input names.
sys = ss(A,B,C,D,Ts,'StateName',{'Position' 'Velocity'},... 'InputName','Force');
The number of state and input names must be consistent with the dimensions of A
, B
, C
, and D
.
Compute the statespace 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 statespace model.
sys = ss(H);
Examine the size of the statespace model.
size(sys)
Statespace 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)
Statespace 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 firstorder system and a secondorder system.
Create a descriptor statespace model (E ≠ I).
a = [2 4; 4 2]; b = [1; 0.5]; c = [0.5, 2]; d = [1]; e = [1 0; 3 0.5]; sysd = dss(a,b,c,d,e);
Compute an explicit realization of the system (E = I).
syse = ss(sysd,'explicit')
syse = A = x1 x2 x1 2 4 x2 20 20 B = u1 x1 1 x2 5 C = x1 x2 y1 0.5 2 D = u1 y1 1 Continuoustime statespace model.
Confirm that the descriptor and explicit realizations have equivalent dynamics.
bodeplot(sysd,syse,'g')
This example shows how to create a statespace
model having both fixed and tunable parameters.genss
where a and b are tunable parameters, whose initial values are 1
and 3
, respectively.
Create the tunable parameters using
.realp
a = realp('a',1); b = realp('b',3);
Define a generalized matrix using algebraic expressions of a
and b
.
A = [1 a+b;0 a*b];
A
is a generalized matrix whose Blocks
property contains a
and b
. The initial value of A
is [1 2;0 3]
, from the initial values of a
and b
.
Create the fixedvalue statespace matrices.
B = [3.0;1.5]; C = [0.3 0]; D = 0;
Use
to create the statespace model.ss
sys = ss(A,B,C,D)
sys = Generalized continuoustime statespace 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 the measured and noise components of an identified polynomial model into two separate statespace models. The former (measured component) can serve as a plant model while the latter can serve as a disturbance model for control system design.
load icEngine z = iddata(y,u,0.04); sys = ssest(z,3); sysMeas = ss(sys,'measured') sysNoise = ss(sys,'noise')
Alternatively, use ss(sys)
to extract the
measured component.