findstates
Estimate initial states of model
Syntax
Description
Examples
Estimate Initial States of a Model
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.
X0 = findstates(nlgr,z,Inf);
Estimate Initial States of State-Space Model
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 iddata1 z1;
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
.
x0est = findstates(model,z1,Inf);
Simulate the model.
opt = simOptions('InitialCondition',x0est);
sim(model,z1(:,[],:),opt);
Selectively Estimate Initial States of a Model
Estimate the initial states of a model selectively by fixing the first state and allowing the second state of the model to be estimated.
Create a nonlinear grey-box model.
FileName = 'dcmotor_m';
Order = [2 1 2];
Parameters = [0.24365;0.24964];
nlgr = idnlgrey(FileName,Order,Parameters);
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.
x0spec = idpar('x0',[0;0]);
x0spec.Free(1) = false;
opt = findstatesOptions;
opt.InitialState = x0spec;
[X0,Report] = findstates(nlgr,z,Inf,opt)
X0 = 2×1
0
0.0061
Report = Status: 'Estimated by simulation error minimization' Method: 'lsqnonlin' Covariance: [2x2 double] DataUsed: [1x1 struct] Termination: [1x1 struct]
Estimate Initial States by Specifying an Initial State Vector
Create a nonlinear grey-box model.
FileName = 'dcmotor_m';
Order = [2 1 2];
Parameters = [0.24365;0.24964];
nlgr = idnlgrey(FileName,Order,Parameters);
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);
Specify an initial guess for the initial states.
x0spec = idpar('x0',[10;10]);
x0spec.Free
is true by default
Estimate the initial states
opt = findstatesOptions; opt.InitialState = x0spec; x0 = findstates(nlgr,z,Inf,opt)
x0 = 2×1
0.0362
-0.1322
Estimate Initial States Using Multi-Experiment Data
Create a nonlinear grey-box model.
FileName = 'dcmotor_m'; Order = [2 1 2]; Parameters = [0.24365;0.24964]; nlgr = idnlgrey(FileName,Order,Parameters); set(nlgr, 'InputName','Voltage','OutputName', ... {'Angular position','Angular velocity'});
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:
Estimate initial state 1 for experiments 1 and 3
Estimate initial state 2 for experiment 1
The fixed initial states have zero values.
x0spec = idpar('x0',zeros(2,3));
x0spec.Free(1,2) = false;
x0spec.Free(2,[2 3]) = false;
opt = findstatesOptions;
opt.InitialState = x0spec;
Estimate the initial states
[X0,EstInfo] = findstates(nlgr,z3,Inf,opt);
Input Arguments
sys
— Identified model
idss
object | idgrey
object | idnlarx
object | idnlhw
object | idnlgrey
object
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 ofsys
is compared to the output signals inData
to determinex0
. Seepredict
for more information.Horizon = Inf
— Minimizes the simulation error. The difference between measured output,Data.y
, and simulated response ofsys
to the measured input data,Data.u
is minimized. Seesim
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 ( | Inf |
Output Error models (trivial noise component):
|
Irrelevant Any value of |
Nonlinear ARX (idnlarx ) | 1 or Inf |
Options
— Estimation options for findstates
findstates
Option set
Estimation options for findstates
, specified
as an option set created using findstatesOptions
Output Arguments
x0
— Estimated initial states
vector | matrix
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.
| ||||||||||||||||
Termination | Termination conditions for the iterative search used for initial state estimation of nonlinear models. Structure with the following fields:
|
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
.
For example:
opt = findstatesOptions;
opt.SearchMethod = 'lsqnonlin';
opt.SearchOptions.Advanced.UseParallel = true;
Version History
Introduced in R2015a
See Also
Ouvrir l'exemple
Vous possédez une version modifiée de cet exemple. Souhaitez-vous ouvrir cet exemple avec vos modifications ?
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
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.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)