Main Content

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™.

CommandDescription
step

Update model parameter estimates using recursive estimation algorithms and real-time data.

step puts the object into a locked state. In a locked state, you cannot change any nontunable properties or input specifications, such as model order, data type, or estimation algorithm. During execution, you can only change tunable properties.

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 obj2 = obj. Any changes made to the properties of the new object created this way (obj2) also change the properties of the original object (obj).

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

  1. 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.

  2. Create an online estimation System object for your model structure by using one of the following commands:

    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.

  3. 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 an iddata object is not supported for online estimation.

  4. 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).

  5. 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 and B), 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 using isLocked. 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 the release command to unlock the System object. You can use release on a System object in code generated from MATLAB, but once you release its resources, you cannot use that System object again.

  6. 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).

  7. 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.

  8. 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

| | | | | | | | | | |

Related Examples

More About