Function File: [sys, x0, info] = n4sid (dat, …)
Function File: [sys, x0, info] = n4sid (dat, n, …)
Function File: [sys, x0, info] = n4sid (dat, opt, …)
Function File: [sys, x0, info] = n4sid (dat, n, opt, …)
Estimate state-space model using N4SID algorithm.
N4SID: Numerical algorithm for Subspace State Space System IDentification.
If no output arguments are given, the singular values are
plotted on the screen in order to estimate the system order.
Inputs
- dat
- iddata set containing the measurements, i.e. time-domain signals.
- n
- The desired order of the resulting state-space system sys.
If not specified, n is chosen automatically according
to the singular values and tolerances.
- …
- Optional pairs of keys and values.
'key1', value1, 'key2', value2.
- opt
- Optional struct with keys as field names.
Struct opt can be created directly or
by function
options. opt.key1 = value1, opt.key2 = value2.
Outputs
- sys
- Discrete-time state-space model.
- x0
- Initial state vector. If dat is a multi-experiment dataset,
x0 becomes a cell vector containing an initial state vector
for each experiment.
- info
- Struct containing additional information.
- info.K
- Kalman gain matrix.
- info.Q
- State covariance matrix.
- info.Ry
- Output covariance matrix.
- info.S
- State-output cross-covariance matrix.
- info.L
- Noise variance matrix factor. LL’=Ry.
Option Keys and Values
- ’n’
- The desired order of the resulting state-space system sys.
s > n > 0.
- ’s’
- The number of block rows s in the input and output
block Hankel matrices to be processed. s > 0.
In the MOESP theory, s should be larger than n,
the estimated dimension of state vector.
- ’alg’, ’algorithm’
- Specifies the algorithm for computing the triangular
factor R, as follows:
- ’C’
- Cholesky algorithm applied to the correlation
matrix of the input-output data. Default method.
- ’F’
- Fast QR algorithm.
- ’Q’
- QR algorithm applied to the concatenated block
Hankel matrices.
- ’tol’
- Absolute tolerance used for determining an estimate of
the system order. If tol >= 0, the estimate is
indicated by the index of the last singular value greater
than or equal to tol. (Singular values less than tol
are considered as zero.) When tol = 0, an internally
computed default value, tol = s*eps*SV(1), is used,
where SV(1) is the maximal singular value, and eps is
the relative machine precision.
When tol < 0, the estimate is indicated by the
index of the singular value that has the largest
logarithmic gap to its successor. Default value is 0.
- ’rcond’
- The tolerance to be used for estimating the rank of
matrices. If the user sets rcond > 0, the given value
of rcond is used as a lower bound for the reciprocal
condition number; an m-by-n matrix whose estimated
condition number is less than 1/rcond is considered to
be of full rank. If the user sets rcond <= 0, then an
implicitly computed, default tolerance, defined by
rcond = m*n*eps, is used instead, where eps is the
relative machine precision. Default value is 0.
- ’confirm’
- Specifies whether or not the user’s confirmation of the
system order estimate is desired, as follows:
- true
- User’s confirmation.
- false
- No confirmation. Default value.
- ’noiseinput’
- The desired type of noise input channels.
- ’n’
- No error inputs. Default value.
$$ x_{k+1} = A x_k + B u_k $$$$ y_k = C x_k + D u_k $$
- ’e’
- Return sys as a (p-by-m+p) state-space model with
both measured input channels u and noise channels e
with covariance matrix Ry.
$$ x_{k+1} = A x_k + B u_k + K e_k $$$$ y_k = C x_k + D u_k + e_k $$
- ’v’
- Return sys as a (p-by-m+p) state-space model with
both measured input channels u and white noise channels v
with identity covariance matrix.
$$ x_{k+1} = A x_k + B u_k + K L v_k $$$$ y_k = C x_k + D u_k + L v_k $$$$ e = L v, \ L L^T = R_y $$
- ’k’
- Return sys as a Kalman predictor for simulation.
$$ \widehat{x}_{k+1} = A \widehat{x}_k + B u_k + K (y_k - \widehat{y}_k) $$$$ \widehat{y}_k = C \widehat{x}_k + D u_k $$
$$ \widehat{x}_{k+1} = (A-KC) \widehat{x}_k + (B-KD) u_k + K y_k $$$$ \widehat{y}_k = C \widehat{x}_k + D u_k + 0 y_k $$
Algorithm
Uses SLICOT SLICOT IB01AD,
Copyright (c) 1996-2025, SLICOT, available under the BSD 3-Clause
(License and Disclaimer).
Source Code:
n4sid