Skip to Main Content Skip to Search
Product Documentation

n4sid - Estimate state-space model using a subspace method.

Syntax

sys = n4sid(data,nx)
sys = n4sid(data,nx,Name,Value)
sys = n4sid(data,nx,___,opt)
[sys,x0] = n4sid(data,nx,___,)

Description

sys = n4sid(data,nx) estimates an nx order state-space model, sys, using measured input-output data, data.

sys is an idss model representing the system:

Here, A,B,C, and D are state-space matrices. K is the disturbance matrix. u(t) is the input, y(t) is the output, x(t) is the vector of nx states and e(t) is the disturbance.

All the entries of the A, B, C and K matrices are considered free estimation parameters. D is fixed to zero, meaning that there is no feedthrough, except for static systems (nx=0).

sys = n4sid(data,nx,Name,Value) specifies additional attributes of the state-space structure using one or more Name,Value pair arguments.

sys = n4sid(data,nx,___,opt) specifies estimation options, opt, that configure the initial states, estimation objective, and sub-space algorithm related choices to be used for estimation.

[sys,x0] = n4sid(data,nx,___,) also returns the estimated initial state.

Input Arguments

data

Estimation data.

For time domain estimation, data is an iddata object containing the input and output signal values.

For frequency domain estimation, data can be one of the following:

  • recorded frequency response data (frd or idfrd)

  • iddata object with its properties specified as follows:

    • InputData — Fourier transform of the input signal

    • OutputData — Fourier transform of the output signal

    • Domain — ‘Frequency'

For multi-experiment data, the sample times and inter-sample behavior of all the experiments must match.

You can only estimate continuous-time models using continuous-time frequency domain data. You can estimate both continuous-time and discrete-time models (of sample time matching that of data) using time-domain data and discrete-time frequency domain data.

nx

Order of estimated model.

Specify nx as a positive integer. nx may be a scalar or a vector. If nx is a vector, then n4sid creates a plot which you can use to choose a suitable model order. The plot shows the Hankel singular values for models of different orders. States with relatively small Hankel singular values can be safely discarded. A default choice is suggested in the plot.

You can also specify nx as 'best', in which case the optimal order is automatically chosen from nx = 1,..,10.

opt

Estimation options.

opt is an options set that specifies estimation options including:

  • estimation objective

  • handling of initial conditions

  • subspace algorithm related choices

Use n4sidOptions to create the options set.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments, where 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.

'Ts'

Sampling time. For continuous-time models, use Ts = 0. For discrete-time models, specify Ts as a positive scalar whose value is equal to that of the data sampling time.

Default: data.Ts

'Form'

Type of canonical form of sys.

Form is a string that takes one of the following values:

  • 'modal' — obtainsys in modal form.

  • 'companion' — obtain sys in companion form.

  • 'free' — all entries of the A, B and C matrices are treated as free.

  • 'canonical' — obtain sys in observable canonical form [1].

Default: 'free'

'Feedthrough'

Logical specifying direct feedthrough from input to output.

Feedthrough is a logical vector of length of length Nu, where Nu is the number of inputs.

If Feedthrough is specified as a logical scalar, it is applied to all the inputs.

Default: false(1,Nu) (Nu is the number of inputs). If the model has no states, then Feedthrough is true(1,Nu).

'DisturbanceModel'

Specifies if the noise component, the K matrix, is to be estimated.

DisturbanceModel takes one of the following values:

  • 'none' — Noise component is not estimated. The value of the K matrix, is fixed to zero value.

  • 'estimate' — The K matrix is treated as a free parameter.

DisturbanceModel must be 'none' when using frequency domain data.

Default: 'estimate' (For time domain data)

'InputDelay'

Input delays. InputDelay is a numeric vector specifying a time delay for each input channel. 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, where each entry is a numerical value representing 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 for all input channels

Output Arguments

sys

Identified state space model.

sys is an idss model, which encapsulates the identified state space model.

x0

Initial states computed during the estimator of sys.

If data contains multiple experiments, then x0 is an array with each column corresponding to an experiment.

Definitions

Modal Form

In modal form, A is a block-diagonal matrix. The block size is typically 1-by-1 for real eigenvalues and 2-by-2 for complex eigenvalues. However, if there are repeated eigenvalues or clusters of nearby eigenvalues, the block size can be larger.

For example, for a system with eigenvalues , the modal A matrix is of the form

Companion Form

In the companion realization, the characteristic polynomial of the system appears explicitly in the rightmost column of the A matrix. For a system with characteristic polynomial

the corresponding companion A matrix is

The companion transformation requires that the system be controllable from the first input. The companion form is poorly conditioned for most state-space computations; avoid using it when possible.

Examples

Build a fifth-order model from data with three inputs and two outputs. Try several choices of N4Horizon. Look at the frequency response of the model.

z = iddata([y1 y2],[ u1 u2 u3]);
opt = n4sidOptions('N4Horizon',[7:15]','Display', 'on');
m = n4sid(z, 5, opt);
h = bodeplot(m)
showConfidence(h)
 

Estimate a continuous-time model, in a canonical form parameterization, focusing on the simulation behavior. Determine the order yourself, in the 1:10 range, after seeing the plot of singular values.

load iddata1 z1
opt = n4sidOptions('Focus','simulation');
m = n4sid(z1, 1:10,'Ts',0,'form','canonical',opt)
bode(m)

References

[1] Ljung, L. System Identification — Theory For the User, Appendix4A, pp 132-134, 2nd ed, PTR Prentice Hall, Upper Saddle River, N.J., 1999.

[2] van Overschee, P., and B. De Moor, Subspace Identification of Linear Systems: Theory, Implementation, Applications, Kluwer Academic Publishers, 1996.

[3] Verhaegen, M., Identification of the deterministic part of MIMO state space models, Automatica, Vol. 30, pp. 61-74, 1994.

[4] Larimore, W.E., Canonical variate analysis in identification, filtering and adaptive control, Proc. 29th IEEE Conference on Decision and Control, pp.596-604, Honolulu, 1990.

See Also

canon | iddata | idfrd | idgrey | idss | n4sidOptions | pem | polyest | procest | ssest | tfest

  


Free Control Systems Interactive Kit

Learn more about resources for designing, testing, and implementing control systems.

Get free kit

Trials Available

Try the latest control systems products.

Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS