You can estimate state-space models in two ways at the command line, depending upon your prior knowledge of the nature of the system and your requirements.
In this approach, you specify the model order, and, optionally,
additional model structure attributes that configure the overall structure
of the state-space matrices. You call
data and model order as primary input arguments, and use name-value
pairs to specify any additional attributes, such as model sample time,
presence of feedthrough, absence of noise component, etc. You do not
work directly with the coefficients of the A, B, C, D, K,
and X0 matrices.
In this approach, you create and configure an
idss model that contains the initial values
for all the system matrices. You use the
idss model to specify all the parameter
constraints. For example, you can designate certain coefficients of
system matrices as fixed and impose minimum/maximum bounds on the
values of the others. For quick configuration of the parameterization
and whether to estimate feedthrough and disturbance dynamics, use
You can estimate continuous-time and discrete-time state-space
models using the iterative estimation command
minimizes the prediction errors to obtain maximum-likelihood values.
Use the following general syntax to both configure and estimate state-space models:
m = ssest(data,n,opt,Name,Value)
data is the estimation data,
the model order, and
opt contains options for configuring
the estimation of the state-space models. These options include the
handling of the initial conditions, input and output offsets, estimation
focus and search algorithm options. opt can be followed by name-value
pair input arguments that specify optional model structure attributes
such as the presence of feedthrough, the canonical form of the model,
and input delay.
m = n4sid(data,n,opt,Name,Value) m = ssregest(data,n,opt,Name,Value)
Unless you specify the sample time as a name-value pair input
a discrete-time model, while
a continuous-time model.
For information about validating your model, see Validating Models After Estimation
By default, all entries of the A, B,
and C state-space matrices are treated as free
parameters. Using the
Form name-value pair input
ssest , you can
choose various canonical forms, such as the companion and modal forms,
that use fewer parameters.
For more information about estimating a specific state-space parameterization, see:
For estimation of state-space models, you have the option of
switching the model sample time between zero and that of the estimation
data. You can do this using the
Ts name-value pair
ssest estimates a
continuous-time model. If you are using data set with nonzero sample
data, which includes all time domain data,
you can also estimate a discrete-time model by using:
model = ssest(data,nx,'Ts',data.Ts);
If you are using continuous-time frequency-domain data, you cannot estimate a discrete-time model.
a model whose sample time matches that of the data. Thus, for time-domain
a discrete-time model. You can estimate a continuous-time model by
model = n4sid(data,nx,'Ts',0);
model = ssregest(data,nx,'Ts',0);
For state-space models with any parameterization, you can specify whether to estimate the D, K and X0 matrices, which represent the input-to-output feedthrough, noise model and the initial states, respectively.
For state-space models with structured parameterization, you
can also specify to estimate the D matrix. However,
for free and canonical forms, the structure of the D matrix
is set based on your choice for the
pair input argument.
By default, the D matrix is not estimated and its value is fixed to zero, except for static models.
Black box estimation: Use
Feedthrough name-value pair input argument
to denote the presence or absence of feedthrough from individual inputs.
For example, in case of a two input model such that there is feedthrough
from only the second input, use:
model = n4sid(data,n,'Feedthrough',[false true]);
Structured estimation: Configure
the values of the
idss model that represents the desired model
structure. To force no feedthrough for the i-th
init_sys.Structure.d.Value(:,i) = 0; init_sys.Structure.d.Free = true; init_sys.Structure.d.Free(:,i) = false;
The first line specifies the value of the i-th column of D as zero. The next line specifies all the elements of D as free, estimable parameters. The last line specifies that the i-th column of the D matrix is fixed for estimation.
K represents the noise matrix of the model, such that the noise component of the model is:.
For frequency-domain data, no noise model is estimated and K is set to 0. For time-domain data, K is estimated by default in the black box estimation setup. yn is the contribution of the disturbances to the model output.
Black box estimation: Use
DisturbanceModel name-value pair input argument
to indicate if the disturbance component is fixed to zero (specify
= ‘none') or estimated as a free parameter
Value = ‘estimate'). For
example, use :
model = n4sid(data,n,'DisturbanceModel','none');
Structured estimation: Configure
the value of the
init_sys is an
that represents the desired model structure. You can fix some K matrix
coefficients to known values and prescribe minimum/maximum bounds
for free coefficients. For example, to estimate only the first column
of the K matrix for a two output model:
kpar = init_sys.Structure.k; kpar.Free(:,1) = true; kpar.Free(:,2) = false; kpar.Value(:,2) = 0; % second column value is fixed to zero init_sys.Structure.k = kpar;
When not sure how to easily fix or free
all coefficients of K, initially you can omit estimating
the noise parameters in K to focus on achieving
a reasonable model for the system dynamics. After estimating the dynamic
model, you can use
ssest to refine the model
while configuring the K parameters to be free.
init_sys = ssest(data, n,'DisturbanceModel','none'); init_sys.Structure.k.Free = true; sys = ssest(data, init_sys);
the dynamic model without noise.
To set K to zero in an existing
model, you can set its
m.Structure.k.Value = 0; m.Structure.k.Free = false;
The initial state vector X0 is obtained as
the by-product of model estimation. The
return the value of X0 as their second output arguments.
You can choose how to handle initial conditions during model estimation
by using the
InitialState estimation option. Use
to create the estimation option set. For example, in order to hold
the initial states to zero during estimation using
opt = n4sidOptions; opt.InitialState = 'zero'; [m,X0] = n4sid(data,n,opt);
X0 variable is a zero vector
When you estimate models using multiexperiment data, the
contains as many columns as data experiments.
For a complete list of values for the
see Specifying Initial States for Iterative Estimation Algorithms.