Perform Online Parameter Estimation at the Command Line
This topic shows how to perform online parameter estimation at the command line. The online estimation commands create a System object™ for your model structure.
Online Estimation System Object
A System object is a specialized MATLAB^{®} object designed specifically for implementing and simulating dynamic systems with inputs that change over time. System objects use internal states to store past behavior, which is used in the next computational step.
After you create a System object, you use commands to process
data or obtain information from or about the object. System objects
use a minimum of two commands to process data — a constructor
to create the object and the step
command
to update object parameters using realtime data. This separation
of declaration from execution lets you create multiple, persistent,
reusable objects, each with different settings.
You can use the following commands with the online estimation System objects in System Identification Toolbox™:
Command  Description 

step  Update model parameter estimates using recursive estimation algorithms and realtime data.

release  Unlock the System object. Use this command to enable setting of nontunable parameters. 
reset  Reset the internal states of a locked System object to the initial values, and leave the object locked. 
clone  Create another System object with the same object property values. Do not create additional objects using
syntax 
isLocked  Query locked status for input attributes and nontunable properties of the System object. 
Note
If all data necessary for estimation is available at once, and you are
estimating a timeinvariant model, use the offline estimation commands for model
parameter estimation. For example, use arx
instead of recursiveARX
.
Workflow for Online Parameter Estimation at the Command Line
Choose a model structure for your application.
Ideally, you want the simplest model structure that adequately captures the system dynamics. For considerations to keep in mind, see Model Structure.
Create an online estimation System object for your model structure by using one of the following commands:
recursiveAR
— Timeseries AR modelrecursiveARMA
— Timeseries ARMA modelrecursiveARX
— SISO or MISO ARX modelrecursiveARMAX
— SISO ARMAX modelrecursiveOE
— SISO outputerror polynomial modelrecursiveBJ
— SISO BoxJenkins polynomial modelrecursiveLS
— Singleoutput system that is linear in estimated parameters
obj = recursiveARX;
You can specify additional object properties such as the recursive estimation algorithm and initial parameter guesses. For information about the algorithms used, see Recursive Algorithms for Online Parameter Estimation.
Acquire inputoutput data in real time.
Specify estimation output data,
y
, as a real scalar, and input data,u
, as a real scalar or vector. Data specified as aniddata
object is not supported for online estimation.Preprocess the estimation data.
Estimation data that contains deficiencies can lead to poor estimation results. Data deficiencies include drift, offset, missing samples, equilibrium behavior, seasonalities, and outliers. Preprocess the estimation data as needed. For considerations to keep in mind, see Estimation Data.
For online parameter estimation at the command line, you cannot use preprocessing tools in System Identification Toolbox. These tools support only data specified as
iddata
objects. Implement preprocessing code as required by your application. To be able to generate C and C++ code, use commands supported by MATLAB Coder™. For a list of these commands, see Functions and Objects Supported for C/C++ Code Generation (MATLAB Coder).Update the parameters of the model using incoming inputoutput data.
Use the
step
command to execute the specified recursive algorithm over each measurement of inputoutput data.[A,B,yhat] = step(obj,y,u);
The output of the
step
command gives the estimated parameters (A
andB
), and estimated model output (yhat
), at each set of inputoutput data.Calling
step
on an object puts that object into a locked state. You can check the locked status of a System object usingisLocked
. When the object is locked, you cannot change any nontunable properties or input specifications such as model order, data type, or estimation algorithm. To change a nontunable property, use therelease
command to unlock the System object. You can userelease
on a System object in code generated from MATLAB, but once you release its resources, you cannot use that System object again.Postprocess estimated parameters.
If necessary, you can postprocess the estimated parameters. For instance, you can use a lowpass filter to smooth out noisy parameter estimates. To be able to generate C and C++ code, use commands supported by MATLAB Coder. For a list of these commands, see Functions and Objects Supported for C/C++ Code Generation (MATLAB Coder).
Validate the online estimation.
For details about the validation, see Validate Online Parameter Estimation at the Command Line. If you are not satisfied with the estimation, use the
reset
command to set the parameters of the System object to their initial value.Use the estimated parameters for your application.
After validating the online parameter estimation, you can use MATLAB Compiler™ or MATLAB Coder to deploy the code in your application.
See Also
recursiveAR
 recursiveARMA
 recursiveARX
 recursiveARMAX
 recursiveOE
 recursiveBJ
 recursiveLS
 step
 reset
 release
 isLocked
 clone
Related Examples
 Validate Online Parameter Estimation at the Command Line
 Generate Code for Online Parameter Estimation in MATLAB
 Line Fitting with Online Recursive Least Squares Estimation
 Online ARX Parameter Estimation for Tracking TimeVarying System Dynamics