Estimate State-Space Model
Estimate state-space model using time or frequency data in the Live Editor
Open the Task
To add the Estimate State-Space Model task to a live script in the MATLAB Editor:
On the Live Editor tab, select Task > Estimate State-Space Model.
In a code block in your script, type a relevant keyword, such as
state
,space
, orestimate
. SelectEstimate State Space Model
from the suggested command completions.
Examples
Parameters
Select DataData Type
— Data type for input and output data
Time
(default) | Frequency
| Data Object
The task accepts numeric measurement values that are uniformly sampled in time.
Input and output signals can contain multiple channels. Data can be packaged as numeric
arrays (for Time
or Frequency
) or in a data
object, such as an iddata
or idfrd
object.
The data type you choose determines whether you must specify additional parameters.
Time
— Specify Sample Time and Start Time in the time units that you select.Frequency
— Specify Frequency by selecting the variable name of a frequency vector in your MATLAB workspace. Specify the units for this frequency vector. Specify Sample Time in seconds.Data Object
— Specify no additional parameters because the data object already contains information on time or frequency sampling.
Estimation Input (u) and Estimation Output (y)
— Variable names of input and output data for estimation
valid variable names
Select the input and output variable names from the MATLAB workspace choices. Use these parameters when Data
Type is Time
or
Frequency
.
Estimation Object
— Variable name of data object containing input and output data for estimation
valid variable name
Select the data object variable name from the MATLAB workspace choices. Use this parameter when Data Type
is Data Object
.
Validation Input (u) and Validation Output (y)
— Variable names of input and output data for validation
valid variable names
Select the input and output variable names from the workspace choices. Use these
parameters when Data Type is Time
or
Frequency
. Specifying validation data is optional but
recommended.
Validation Object
— Variable name of data object containing input and output data for validation
valid variable name
Select the data object variable name from the MATLAB workspace choices. Use this parameter when Data Type
is Data Object
. Specifying validation data is optional but
recommended.
Plant Order
— Order of model to estimate
4 (default) | integer scalar | integer range
The task allows you to specify a single value or a range of values for the order of the model to estimate.
Specify value
— Specify the order of the model explicitly.Pick best value in range
— Specify a range of values, such as1:10
. When you run the task, the Hankel singular-value plot visualizes the relative energy contribution of each state in the estimated model and recommends the lowest order that reproduces critical dynamic behavior. Proceed with this recommendation or select another order in Chosen Order. Click Apply to accept the model order and proceed.
Time Domain
— Continuous or discrete time domain
Continuous
(default) | Discrete
Select a continuous-time or discrete-time model.
Estimate Disturbance
— Include disturbance in estimation model
off (default) | on
Select this option to estimate the disturbance model. When you select this option, the model equations update to show the K matrix and e term.
Input Channel
— Set input channel delay and feedthrough options
u1 (default) | u2 | ...
For each input channel, assign values for Input Delay and Feedthrough.
Input Channel — Select an input channel. The input channel is always of the form
u
i, where i is the ith channel of the inputu
.Input Delay — Enter the input delay in number of samples (discrete-time model) or number of time units (continuous-time model) for the channel. For instance, to specify a 0.2-second input delay for a continuous-time system for which the time unit is
milliseconds
, enter200
.Feedthrough — Select this option to estimate channel feedthrough from input to output. When you select this option, the model equations update to show the Du term.
Fit Focus
— Minimize prediction error or simulation error
Prediction
(default) | Simulation
Fit focus specifies what error to minimize in the loss function during estimation.
Prediction
— Minimize the one-step-ahead prediction error between measured and predicted outputs. This estimation approach focuses on producing a good predictor model for the estimation inputs and outputs. Prediction focus generally produces the best estimation results because it uses both input and output measurements, thus accounting for disturbances.Simulation
— Minimize the error between measured and simulated outputs. This estimation approach focuses on producing a simulated model response that has a good fit with the estimation inputs and outputs. Simulation focus is generally best for validation, especially with data sets not used for the original estimation.
Initial Conditions
— Handling of initial states
Auto
(default) | Zero
| Estimate
| Backcast
Set this option when you want to choose a specific method for initializing the model
states. With the default setting of Auto
, the software
chooses the method based on the estimation data. Choices are:
Zero
— The initial state is set to zero.Estimate
— The initial state is treated as an independent estimation parameter.Backcast
— The initial state is estimated using the best least-squares fit.
Input Intersampling
— Intersampling behavior for input signal
Zero-order hold
(default) | Triangle approximation
| Band-limited
Input intersampling is a property of the input data. The task uses this property
when estimating continuous models. Specify Input Intersampling when
your data type is Time
or
Frequency
. If you are using an iddata
object, the object already contains the intersampling information. Choices for this
property are:
Zero-order hold
— Piecewise-constant input signal between samplesTriangle approximation
— Piecewise-linear input signal between samples, also known as first-order holdBand-limited
— Input signal has zero power above the Nyquist frequency
Search Method
— Numerical search mode for iterative parameter estimation
Auto
(default) | Gauss-Newton
| Adaptive Gauss-Newton
| Levenberg-Marquardt
| Gradient Search
Auto
— For each iteration, the software cycles through the methods until it finds the first direction descent that leads to a reduction in estimation cost.Gauss-Newton
— Subspace Gauss-Newton least-squares search.Levenberg-Marquardt
— Levenberg-Marquardt least-squares search.Adaptive Gauss-Newton
—Adaptive subspace Gauss-Newton search.Gradient Search
— Steepest descent least-squares search.
Max. Iterations
— Maximum number of iterations during error minimization
20 (default) | positive integer
Set the maximum number of iterations during error minimization. The iterations stop when Max. Iterations is reached or another stopping criterion is satisfied, such as Tolerance.
Tolerance
— Minimum percentage of expected improvement in error
0.01 (default) | positive integer
When the percentage of expected improvement is less than Tolerance, the iterations stop.
Weighting Prefilter
— Weighting prefilter for loss function
No filter
(default) | Passband(s)
| LTI Filter
| Frequency weights vector
| Inverse of magnitude of the frequency response
| Inverse of square root of magnitude of the frequency
response
Set this option when you want to apply a weighting prefilter to the loss function that the task minimizes when you estimate the model. When you select an option, you must also select the associated variable in your workspace that contains the filter information. The available options depend on the domain of the data.
Weighting Prefilter | Data Domain | Filter Information |
---|---|---|
No Filter | Time and frequency | |
Passbands | Time and frequency | Passband ranges, specified as a 1-by-2 row vector or an n-by-2 matrix, where n is the number of passbands. |
LTI Filter | Time and frequency | SISO LTI model. |
Frequency Weights Vector | Frequency | Frequency weights, specified as a column vector with the same length as the frequency vector. |
Inverse of magnitude of the frequency
response | Frequency response | The weighting filter is, where G(ω) is the complex frequency-response data. SISO and SIMO systems only. |
Inverse of square root of magnitude of the frequency
response | Frequency response | The weighting filter is . SISO and SIMO systems only. |
For instance, suppose that you are performing estimation with SISO
frequency-domain data and that in your MATLAB workspace, you have a column vector W
that contains
frequency weights for the prefilter. In the task, select Weighting
prefilter > Frequency weights vector and the variable
W
.
Output Plot
— Plot comparison of model and measured outputs
on (default) | off
Plot a comparison of the model output and the original measured data, along with the fit percentage. If you have separate validation data, a second plot compares the model response to the validation input data with the measured output from the validation data set.
Version History
Introduced in R2019b