Accelerating the pace of engineering and science

# idss

State-space model with identifiable parameters

## Syntax

• sys = idss(A,B,C,D)
• sys = idss(A,B,C,D,K)
• sys = idss(A,B,C,D,K,x0)
• sys = idss(A,B,C,D,K,x0,Ts)
• sys = idss(___,Name,Value)
• sys = idss(sys0)
• sys = idss(sys0,'split')

## Description

sys = idss(A,B,C,D) creates a state-space model with identifiable parameters. A, B, C, and D are the initial values of the state-space matrices. By default, sys is discrete-time model with unspecified sampling time and no state disturbance element.

sys = idss(A,B,C,D,K) creates a state-space model with a disturbance element given by the matrix K.

sys = idss(A,B,C,D,K,x0) creates a state-space model with initial state values given by the vector x0.

sys = idss(A,B,C,D,K,x0,Ts) creates a state-space model with sampling time Ts. Use Ts = 0 to create a continuous-time model.

sys = idss(___,Name,Value) creates a state-space model using additional options specified by one or more Name,Value pair arguments.

sys = idss(sys0) converts any dynamic system model, sys0, to idss model form.

sys = idss(sys0,'split') converts sys0 to idss model form, and treats the last Ny input channels of sys0 as noise channels in the returned model. sys0 must be a numeric (non-identified) tf, zpk, or ss model object. Also, sys0 must have at least as many inputs as outputs.

## Object Description

An idss model represents a system as a continuous-time or discrete-time state-space model with identifiable (estimable) coefficients.

A state-space model of a system with input vector u, output vector y, and disturbance e takes the following form in continuous time:

$\begin{array}{c}\frac{dx\left(t\right)}{dt}=Ax\left(t\right)+Bu\left(t\right)+Ke\left(t\right)\\ y\left(t\right)=Cx\left(t\right)+Du\left(t\right)+e\left(t\right).\end{array}$

In discrete time, the state-space model takes the form:

$\begin{array}{c}x\left[k+1\right]=Ax\left[k\right]+Bu\left[k\right]+Ke\left[k\right]\\ y\left[k\right]=Cx\left[k\right]+Du\left[k\right]+e\left[k\right].\end{array}$

For idss models, the elements of the state-space matrices A, B, C, and D can be estimable parameters. The elements of the state disturbance K can also be estimable parameters. The idss model stores the values of these matrix elements in the a, b, c, d, and k properties of the model.

There are three ways to obtain an idss model.

• Estimate the idss model based on input-output measurements of a system, using n4sid or ssest. These estimation commands estimate the values of the estimable elements of the state-space matrices. The estimated values are stored in the a, b, c, d, and k properties of the resulting idss model. The Report property of the resulting model stores information about the estimation, such as handling of initial state values and options used in estimation.

When you obtain an idss model by estimation, you can extract estimated coefficients and their uncertainties from the model using commands such as idssdata, getpar, or getcov.

• Create an idss model using the idss command.

You can create an idss model to configure an initial parameterization for estimation of a state-space model to fit measured response data. When you do so, you can specify constraints on one or more of the state-space matrix elements. For example, you can fix the values of some elements, or specify minimum or maximum values for the free elements. You can then use the configured model as an input argument to an estimation command (n4sid or ssest) to estimate parameter values with those constraints.

• Convert an existing dynamic system model to an idss model using the idss command.

To configure an idss model in a desired form, such as a companion or modal form, use state transformation commands such as canon and ss2ss.

## Examples

expand all

### Create State-Space Model with Identifiable Parameters

Create a 4th-order SISO state-space model with identifiable parameters. Initialize the initial state values to 0.1 for all entries. Set the sampling time to 0.1 s as well.

```A = blkdiag([-0.1 0.4; -0.4 -0.1],[-1 5; -5 -1]);
B = [1; zeros(3,1)];
C = [1 0 1 0];
D = 0;
K = zeros(4,1);
x0 = [0.1,0.1,0.1,0.1];
Ts = 0.1;

sys = idss(A,B,C,D,K,x0,Ts);
```

sys is a 4th-order, SISO idss model. The number of states and input-output dimensions are determined by the dimensions of the state-space matrices. By default, all entries in the matrices A, B, C, D, and K are identifiable parameters.

You can use sys to specify an initial parametrization for state-space model estimation with ssest or n4sid.

### Specify Additional Attributes of State-Space Model

Create a 4th-order SISO state-space model with identifiable parameters. Name the input and output channels of the model, and specify minutes for the model time units.

You can use Name,Value pair arguments to specify additional model properties on model creation.

```A = blkdiag([-0.1 0.4; -0.4 -0.1],[-1 5; -5 -1]);
B = [1; zeros(3,1)];
C = [1 0 1 0];
D = 0;

sys = idss(A,B,C,D,'InputName','Drive','TimeUnit','minutes');
```

To change or specify most attributes of an existing model, you can use dot notation. For example:

```sys.OutputName = 'Torque';
```

### Configure Identifiable Parameters of State-Space Model

Configure an idss model so that it has no state disturbance element and only the non-zero entries of the A matrix are estimable. Additionally, fix the values of the B matrix.

You can configure individual parameters of an idss model to specify constraints for state-space model estimation with ssest or n4sid.

Create an idss model.

```A = blkdiag([-0.1 0.4; -0.4 -0.1],[-1 5; -5 -1]);
B = [1; zeros(3,1)];
C = [1 0 1 0];
D = 0;
K = zeros(4,1);
x0 = [0.1,0.1,0.1,0.1];

sys = idss(A,B,C,D,K,x0,0);
```

Setting all entries of K = 0 creates an idss model with no state disturbance element.

Use the Structure property of the model to fix the values of some of the parameters.

```sys.Structure.a.Free = (A~=0);
sys.Structure.b.Free = false;
sys.Structure.k.Free = false;
```

The entries in sys.Structure.a.Free determine whether the corresponding entries in sys.a are free (identifiable) or fixed. The first line sets sys.Structure.a.Free to a logical matrix that is true wherever A is non-zero, and false everywhere else. Doing so fixes the value of the zero entries in sys.a.

The remaining lines fix all the values in sys.b and sys.k to the values you specified when you created the model.

### Array of State-Space Models

Create an array of state-space models.

There are several ways to create arrays of state-space models:

• Direct array construction using -dimensional state-space arrays

• Array-building by indexed assignment

• Array-building using the stack command

• Sampling an identified model using the rsample command

Create an array by providing -dimensional arrays as an input argument to idss, instead of 2-dimensional matrices.

```A = rand(2,2,3,4);
sysarr = idss(A,[2;1],[1 1],0);
```

When you provide a multi-dimensional array to idss in place of one of the state-space matrices, the first two dimensions specify the numbers of states, inputs, or outputs of each model in the array. The remaining dimensions specify the dimensions of the array itself. A is a 2-by-2-by-3-by-4 array. Therefore, sysarr is a 3-by-4 array of idss models. Each model in sysarr has two states, specified by the first two dimensions of A. Further, each model in sysarr has the same B, C, and D values.

Create an array by indexed assignment.

```sysarr = idss(zeros(1,1,2));
sysarr(:,:,1) = idss([4 -3;-2 0],[2;1],[1 1],0);
sysarr(:,:,2) = idss(rand(2),rand(2,1),rand(1,2),1);
```

The first command preallocates the array. The first two dimensions of the array are the I/O dimensions of each model in the array. Therefore, sysarr is a 2-element vector of SISO models.

The remaining commands assign an idss model to each position in sysarr. Each model in an array must have the same I/O dimensions.

Add another model to sysarr using stack.

stack is an alternative to building an array by indexing.

```sysarr = stack(1,sysarr,idss([1 -2;-4 9],[0;-1],[1 1],0));
```

This command adds another idss model along the first array dimension of sysarr. sysarr is now a 3-by-1 array of SISO idss models

## Input Arguments

 A,B,C,D Initial values of the state-space matrices. For a system with Ny outputs, Nu inputs, and Nx states, specify initial values of the state-space matrix elements as follows: A — Nx-by-Nx matrix.B — Nx-by-Nu matrix.C — Ny-by-Nx matrix.D — Ny-by-Nu matrix. Use NaN for any matrix element whose initial value is not known. K Initial value of the state disturbance matrix. Specify K as an Nx-by-Ny matrix. Use NaN for any matrix element whose initial value is not known. Default: Nx-by-Ny zero matrix. x0 Initial state values. Specify the initial condition as a column vector of Nx values. Default: Nx column vector of zeros. Ts Sampling time. For continuous-time models, Ts = 0. For discrete-time models, Ts is a positive scalar representing the sampling period expressed in the unit specified by the TimeUnit property of the model. To denote a discrete-time model with unspecified sampling time, set Ts = -1. Default: –1 (discrete-time model with unspecified sampling time) sys0 Dynamic system. Any dynamic system to convert to an idss model: When sys0 is an identified model, its estimated parameter covariance is lost during conversion. If you want to translate the estimated parameter covariance during the conversion, use translatecov.When sys0 is a numeric (non-identified) model, the state-space data of sys0 define the A, B, C, and D matrices of the converted model. The disturbance matrix K is fixed to zero. The NoiseVariance value defaults to eye(Ny), where Ny is the number of outputs of sys. For the syntax sys = idss(sys0,'split'), sys0 must be a numeric (non-identified) tf, zpk, or ss model object. Also, sys0 must have at least as many inputs as outputs. Finally, the subsystem sys0(:,Ny+1:Ny+Nu) must contain a non-zero feedthrough term (the subsystem must be biproper).

### Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Use Name,Value arguments to specify additional properties of idss models during model creation. For example, idss(A,B,C,D,'InputName','Voltage') creates an idss model with the InputName property set to Voltage.

## Properties

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

idss object properties include:

 a,b,c,d Values of state-space matrices. a — State matrix A, an Nx-by-Nx matrix.b — Nx-by-Nu matrix.c — Ny-by-Nx matrix.d — Ny-by-Nu matrix. If you create an idss model sys using the idss command, sys.a, sys.b, sys.c, and sys.d contain the initial values of the state-space matrices that you specify with the A,B,C,D input arguments. If you obtain an idss model sys by identification using ssest or n4sid, then sys.a, sys.b, sys.c, and sys.d contain the estimated values of the matrix elements. For an idss model sys, each property sys.a, sys.b, sys.c, and sys.d is an alias to the corresponding Value entry in the Structure property of sys. For example, sys.a is an alias to the value of the property sys.Structure.a.Value. k Value of state disturbance matrix K, an Nx-by-Ny matrix. If you create an idss model sys using the idss command, sys.k contains the initial values of the state-space matrices that you specify with the K input argument. If you obtain an idss model sys by identification using ssest or n4sid, then sys.k contains the estimated values of the matrix elements. For an idss model sys, sys.k is an alias to the value of the property sys.Structure.k.Value. Default: Nx-by-Ny zero matrix. StateName State names. For first-order models, set StateName to a string. For models with two or more states, set StateName to a cell array of strings . Use an empty string '' for unnamed states. Default: Empty string '' for all states StateUnit State units. Use StateUnit to keep track of the units each state is expressed in. For first-order models, set StateUnit to a string. For models with two or more states, set StateUnit to a cell array of strings. StateUnit has no effect on system behavior. Default: Empty string '' for all states Structure Information about the estimable parameters of the idss model. Structure.a, Structure.b, Structure.c, Structure.d, and Structure.k contain information about the A, B, C, D, and K matrices, respectively. Each contains the following fields:Value — Parameter values. For example, sys.Structure.a.Value contains the initial or estimated values of the A matrix. NaN represents unknown parameter values. Each property sys.a, sys.b, sys.c, and sys.d is an alias to the corresponding Value entry in the Structure property of sys. For example, sys.a is an alias to the value of the property sys.Structure.a.ValueMinimum — Minimum value that the parameter can assume during estimation. For example, sys.Structure.k.Minimum = 0 constrains all entries in the K matrix to be greater than or equal to zero. Maximum — Maximum value that the parameter can assume during estimation.Free — Boolean specifying whether the parameter is a free estimation variable. If you want to fix the value of a parameter during estimation, set the corresponding Free = false. For example, if A is a 3-by-3 matrix, sys.Structure.a.Free = eyes(3) fixes all of the off-diagonal entries in A, to the values specified in sys.Structure.a.Value. In this case, only the diagonal entries in A are estimable. Scale — Scale of the parameter's value. Scale is not used in estimation.Info — Structure array for storing parameter units and labels. The structure has Label and Unit fields.Use these fields for your convenience, to store strings that describe parameter units and labels. NoiseVariance The variance (covariance matrix) of the model innovations e. An identified model includes a white, Gaussian noise component e(t). NoiseVariance is the variance of this noise component. Typically, the model estimation function (such as ssest) determines this variance. For SISO models, NoiseVariance is a scalar. For MIMO models, NoiseVariance is a Ny-by-Ny matrix, where Ny is the number of outputs in the system. Report Information about the estimation process. Report contains the following fields: N4Weight — Subspace algorithm option value used by n4sid estimator (see n4sidOptions).N4Horizon — Forward and backward prediction horizons used by n4sid (see n4sidOptions).InitialState — Whether initial state values were estimated or fixed.Fit — Quantitative quality assessment of estimation, including percent fit to data and final prediction error.Parameters — Estimated values of model parameters and initial states, and their covariances.OptionsUsed — Options used during estimation (see ssestOptions or n4sidOptions).RandState — Random number stream state at start of estimation.Status — Whether model was obtained by construction, estimated, or modified after estimation.Method — Name of estimation method used.DataUsed — Attributes of data used for estimation, such as name and sampling time.Termination — Termination conditions for the iterative search scheme used for prediction error minimization, such as final cost value or stopping criterion. Available only when the model is estimated using ssest or pem. 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 sampling period Ts. For example, InputDelay = 3 means a delay of three sampling periods. 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. For identified systems, like idss, OutputDelay is fixed to zero. Ts Sampling time. For continuous-time models, Ts = 0. For discrete-time models, Ts is a positive scalar representing the sampling period expressed in the unit specified by the TimeUnit property of the model. To denote a discrete-time model with unspecified sampling 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 sampling time of a discrete-time system. Default: –1 (discrete-time model with unspecified sampling time) TimeUnit String representing the unit of the time variable. This property specifies the units for the time variable, the sampling time Ts, and any time delays in the model. Use any 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. Set InputName to a string for single-input model. For a multi-input model, set InputName to a cell array of strings. Alternatively, use automatic vector expansion to assign input names for multi-input models. For example, if sys is a two-input model, enter: `sys.InputName = 'controls';` The input names automatically expand to {'controls(1)';'controls(2)'}. When you estimate a model using an iddata object, data, the software automatically sets InputName to data.InputName. 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 plotsExtracting subsystems of MIMO systemsSpecifying connection points when interconnecting models Default: Empty string '' for all input channels InputUnit Input channel units. Use InputUnit to keep track of input signal units. For a single-input model, set InputUnit to a string. For a multi-input model, set InputUnit to a cell array of strings. InputUnit has no effect on system behavior. Default: Empty string '' 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. Set OutputName to a string for single-output model. For a multi-output model, set OutputName to a cell array of strings. Alternatively, use automatic vector expansion to assign output names for multi-output models. For example, if sys is a two-output model, enter: `sys.OutputName = 'measurements';` The output names to automatically expand to {'measurements(1)';'measurements(2)'}. When you estimate a model using an iddata object, data, the software automatically sets OutputName to data.OutputName. 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 plotsExtracting subsystems of MIMO systemsSpecifying connection points when interconnecting models Default: Empty string '' for all input channels OutputUnit Output channel units. Use OutputUnit to keep track of output signal units. For a single-output model, set OutputUnit to a string. For a multi-output model, set OutputUnit to a cell array of strings. OutputUnit has no effect on system behavior. Default: Empty string '' for all input 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: ```sys.OutputGroup.temperature = [1]; sys.InputGroup.measurement = [3 5];``` 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. Set Name to a string to label the system. Default: '' Notes Any text that you want to associate with the system. Set Notes to a string or a cell array of strings. Default: {} UserData Any type of data you wish to associate with system. Set UserData to any MATLAB® data type. Default: [] SamplingGrid Sampling grid for model arrays, specified as a data structure. For arrays of identified linear (IDLTI) models that are derived by sampling one or more independent variables, this property tracks the variable values associated with each model. 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, if you collect data at various operating points of a system, you can identify a model for each operating point separately and then stack the results together into a single system array. You can tag the individual models in the array with information regarding the operating point: ```nominal_engine_rpm = [1000 5000 10000]; sys.SamplingGrid = struct('rpm', nominal_engine_rpm)``` where sys is an array containing three identified models obtained at rpms 1000, 5000 and 10000, respectively. Default: []