x0 = findstates(sys,Data) estimates
the initial states, x0, of an identified model sys,
to maximize the fit between the model response and the output signal
in the estimation data.
Create a nonlinear grey-box model. The model is a linear DC motor with one input (voltage), and two outputs (angular position and angular velocity). The structure of the model is specified by dcmotor_m.m file.
FileName = 'dcmotor_m';
Order = [2 1 2];
Parameters = [0.24365;0.24964];
nlgr = idnlgrey(FileName,Order,Parameters);
nlgr = setinit(nlgr, 'Fixed', false(2,1)); % set initial states free
Load data for initial state estimation.
load(fullfile(matlabroot,'toolbox','ident',...'iddemos','data','dcmotordata'));
z = iddata(y,u,0.1);
Estimate the initial states such that the model's response using the estimated states X0 and measured input u is as close as possible to the measured output y.
Estimate an idss model and simulate it such that the response of the estimated model matches the estimation data's output signal as closely as possible.
Load sample data.
load iddata1z1;
Estimate a linear model from the data.
model = ssest(z1,2);
Estimate the value of the initial states to best fit the measured output z1.y.
The model is a linear DC motor with one input (voltage), and two outputs (angular position and angular velocity). The structure of the model is specified by dcmotor_m.m file.
Load the estimation data.
load(fullfile(matlabroot,'toolbox','ident',...'iddemos','data','dcmotordata'));
z = iddata(y,u,0.1);
Hold the first state fixed at zero, and estimate the value of the second.
The model is a linear DC motor with one input (voltage), and two outputs (angular position and angular velocity). The structure of the model is specified by dcmotor_m.m file.
Load the estimation data.
load(fullfile(matlabroot,'toolbox','ident',...'iddemos','data','dcmotordata'));
z = iddata(y,u,0.1);
The model is a linear DC motor with one input (voltage), and two outputs (angular position and angular velocity). The structure of the model is specified by dcmotor_m.m file.
Load the estimation data.
load(fullfile(matlabroot,'toolbox','ident',...'iddemos','data','dcmotordata'));
z = iddata(y,u,0.1,'Name','DC-motor',...'InputName','Voltage','OutputName',...
{'Angular position','Angular velocity'});
Create a three-experiment data set.
z3 = merge(z,z,z);
Choose experiment for estimating the initial states:
Identified model whose initial states are estimated, represented
as a linear state-space (idss or idgrey)
or nonlinear model (idnlarx, idnlhw,
or idnlgrey).
Data — Estimation data iddata object
Estimation data, specified as an iddata object
with input/output dimensions that match sys.
If sys is a linear model, Data can
be a frequency-domain iddata object. For easier
interpretation of initial conditions, make the frequency vector of Data be
symmetric about the origin. For converting time-domain data into frequency-domain
data, use fft with 'compl' input
argument, and ensure that there is sufficient zero padding. Scale
your data appropriately when you compare x0 between
the time-domain and frequency-domain. Since for an N-point
fft, the input/output signals are scaled by 1/sqrt(N),
the estimated x0 vector is also scaled by this
factor.
Horizon — Prediction horizon for computing model response 1 (default) | positive integer between 1 and Inf
Prediction horizon for computing the response of sys,
specified as a positive integer between 1 and Inf.
The most common values used are:
Horizon = 1 — Minimizes
the 1-step prediction error. The 1–step ahead prediction response
of sys is compared to the output signals in Data to
determine x0. See predict for
more information.
Horizon = Inf — Minimizes
the simulation error. The difference between measured output, Data.y,
and simulated response of sys to the measured
input data, Data.u is minimized. See sim for more information.
Specify Horizon as any positive integer
between 1 and Inf, with the following restrictions:
Scenario
Horizon
Continuous-time model with time-domain data
1 or Inf
Continuous-time frequency-domain data (data.Ts =
0)
Estimated initial states of model sys,
returned as a vector or matrix. For multi-experiment data, x0 is
a matrix with one column for each experiment.
Report — Initial state estimation information structure
Initial state estimation information, returned as a structure. Report contains
information about the data used, state covariance, and results of
any numerical optimization performed to search for the initial states. Report has
the following fields:
Report Field
Description
Status
Summary of how the initial state were estimated.
Method
Search method used.
Covariance
Covariance of state estimates, returned as a Ns-by-Ns matrix,
where Ns is the number of states.
DataUsed
Attributes of the data used for estimation, returned
as a structure with the following fields:
Field
Description
Name
Name of the data set.
Type
Data type.
Length
Number of data samples.
Ts
Sample time.
InterSample
Input intersample behavior, returned as one of the following
values:
'zoh' — Zero-order hold
maintains a piecewise-constant input signal between samples.
'foh' — First-order hold
maintains a piecewise-linear input signal between samples.
'bl' — Band-limited behavior
specifies that the continuous-time input signal has zero power above
the Nyquist frequency.
InputOffset
Offset removed from time-domain input data during estimation.
For nonlinear models, it is [].
OutputOffset
Offset removed from time-domain output data during estimation.
For nonlinear models, it is [].
Termination
Termination conditions for the iterative search used
for initial state estimation of nonlinear models. Structure with the
following fields:
Field
Description
WhyStop
Reason for terminating the numerical search.
Iterations
Number of search iterations performed by the estimation
algorithm.
FirstOrderOptimality
-norm of the gradient search
vector when the search algorithm terminates.
FcnCount
Number of times the objective function was called.
UpdateNorm
Norm of the gradient search vector in the last iteration.
Omitted when the search method is 'lsqnonlin' or 'fmincon'.
LastImprovement
Criterion improvement in the last iteration, expressed
as a percentage. Omitted when the search method is 'lsqnonlin' or 'fmincon'.
Algorithm
Algorithm used by 'lsqnonlin' or 'fmincon' search
method. Omitted when other search methods are used.
Termination is
empty for linear models.
Extended Capabilities
Automatic Parallel Support Accelerate code by automatically running computation in parallel using Parallel Computing Toolbox™.
Parallel computing support is available for estimation using the
lsqnonlin search method (requires Optimization Toolbox™). To enable parallel computing, use findstatesOptions, set SearchMethod to
'lsqnonlin', and set
SearchOptions.Advanced.UseParallel to
true.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.