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 real-time 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 real-time 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 time-invariant 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
— Time-series AR modelrecursiveARMA
— Time-series ARMA modelrecursiveARX
— SISO or MISO ARX modelrecursiveARMAX
— SISO ARMAX modelrecursiveOE
— SISO output-error polynomial modelrecursiveBJ
— SISO Box-Jenkins polynomial modelrecursiveLS
— Single-output 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 input-output 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 input-output data.
Use the
step
command to execute the specified recursive algorithm over each measurement of input-output 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 input-output 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.Post-process estimated parameters.
If necessary, you can post-process the estimated parameters. For instance, you can use a low-pass 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 Time-Varying System Dynamics