The toolbox provides identification techniques such as maximum likelihood, prediction-error minimization (PEM), and subspace system identification. To represent nonlinear system dynamics, you can estimate Hammerstein-Weiner models and nonlinear ARX models with wavelet network, tree-partition, and sigmoid network nonlinearities. The toolbox performs grey-box system identification for estimating parameters of a user-defined model. You can use the identified model for system response prediction and plant modeling in Simulink. The toolbox also supports time-series data modeling and time-series forecasting.
2 Identify Linear Models Using System Identification App
Objectives Estimate and validate linear models from single-input/single-output (SISO) data to find the one that best describes the system dynamics.
Import data arrays from the MATLAB® workspace into the app
Plot the data
Process data by removing offsets from the input and output signals.
Estimate, validate, and compare linear models.
Export models to the MATLAB workspace.
Example:
This system heats the air at the inlet using a mesh of resistor wire, similar to a hair dryer. The input is the power supplied to the resistor wires, and the output is the air temperature at the outlet.
2.1 Preparing Data for System Identification
Loading Data into the MATLAB Workspace
Opening the System Identification App
Importing Data Arrays into the System Identification App
Plotting and Processing Data
Step1:load dryer2 // Loading Data into the MATLAB Workspace: input data:u2(1000*1-double);output data:y2(1000*1-double)
Step2:systemIdentification // Opening the System Identification App
Step3://To import data arrays into the System Identification app:
//(1)Select Import data > Time domain data. This action opens the Import Data dialog box.
//(2)In the Import Data dialog box, specify the following options:
1)Input—Enter u2 as the name of the input variable.
2)Output—Enter y2 as the name of the output variable.
3)Data name —Change the default name to data.This name labels the data in the SystemIdentification app after the import operation is completed.
4)Starting time —Enter0as the starting time.This value designates the starting value of the time axis on time plots.
5)SampleTime—Enter0.08as the time between successive samples in seconds.This value is the actual sample time in the experiment.
//(3)In the Data Information area, click More to expand the dialog box and specify the following options:
1)InputProperties
InterSample—Accept the default zoh (zero-order hold) to indicate that the input signal was piecewise-constant between samples during data acquisition.This setting specifies the behavior of the input signals between samples when you transform the resulting models between discrete-time and continuous-time representations.
Period—Accept the default inf to specify a nonperiodic input.
2)ChannelNames
Input—Enter power.
Tip:Naming channels helps you to identify data in plots.For multivariable input and output signals, you can specify the names of individual InputandOutput channels, separated by commas.
Output—Enter temperature.
3)PhysicalUnits of Variables
Input—Enter W for power units.
Tip:When you have multiple inputs and outputs, enter a comma-separated list of InputandOutput units corresponding to each channel.
Output—Enter^oC for temperature units.
4)ClickImport to add the data to the SystemIdentification app.The app displays an icon to represent the data.
5)ClickClose to close the ImportData dialog box.
Step4://Plotting and Processing Data
(1)Plot the data.
//Select the Time plot check box to open the Time Plot. If the plot window is empty, click the data icon in the System Identification app.
(2)Remove offsets from the data by subtracting the mean values of the input and the output.
//1)Subtract the mean input value from the input data and the mean output value from the output data. In the System Identification app, select <--Preprocess > Remove means.
//2)Specify the detrended data to be used for estimating models. Drag the data set datad to the Working Data rectangle.
(3)Split the data into two parts to use one part model estimation and the other part for model validation.
//Split the data into two parts and specify the first part for model estimation, and the second part for model validation.
a)Select<--Preprocess>Select range to open the SelectRange window.
b)In the SelectRange window, create a data set containing the first 500 samples.In the Samples field, specify 1500.
c)In the Data name field, type the name data_est.
d)ClickInsert to add thisnew data set to the SystemIdentification app to be used for model estimation.
e)Repeatthis process to create a second data set containing a subset of the data to usefor validation.In the SelectRange window, specify the last500 samples in the Samples field.Type the name data_val in the Data name field.ClickInsert to add thisnew data set to the SystemIdentification app.
f)ClickClose to close the SelectRange window.
//In the System Identification app, drag and drop data_est to the Working Data rectangle, and drag and drop data_val to the Validation Data rectangle.
//To get information about a data set, right-click its icon. For example, right-click data_est to open the Data/model Info dialog box.
2.2 Estimating Linear Models Using Quick Start
How to Estimate Linear Models Using Quick Start
Types of Quick Start Linear Models
Validating the Quick Start Models
How to Estimate Linear Models Using Quick Start
You can use the Quick Start feature in the System Identification app to estimate linear models. Quick Start might produce the final linear models you decide to use, or provide you with information required to configure the estimation of accurate parametric models, such as time constants, input delays, and resonant frequencies.
Step1:In the SystemIdentification app ,selectEstimate>Quick start.
//This action generates plots of step response, frequency-response, and the output of state-space and polynomial models. For more information about these plots, see Validating the Quick Start Models.
Types of Quick Start Linear Models
imp — Step response over a period of time using the impulse algorithm.
spad — Frequency response over a range of frequencies using the spa algorithm. The frequency response is the Fourier transform of the impulse response of a linear system.
By default, the model is evaluated at 128 frequency values, ranging from 0 to the Nyquist frequency.
arxqs — Fourth-order autoregressive (ARX) model using the arx algorithm.
This model is parametric and has the following structure:
In arxqs, , and is estimated from the step response model imp.
n4s3 — State-space model calculated using n4sid. The algorithm automatically selects the model order (in this case, 3).
This model is parametric and has the following structure:
y(t) represents the output at time t, u(t) represents the input at time t, x is the state vector, and e(t) is the white-noise disturbance. The System Identification Toolbox product estimates the state-space matrices A, B, C, D, and K.
Validating the Quick Start Models
Quick Start generates the following plots during model estimation to help you validate the quality of the models:
Step-response plot
You can use the step-response plot to estimate the dead time of linear systems. For example, the previous step-response plot shows a time delay of about 0.25 s before the system responds to the input. This response delay, or dead time, is approximately equal to about three samples because the sample time is 0.08 s for this data set.
Frequency-response plot
Model-output plot
The model-output plot shows the model response to the input in the validation data. The fit values for each model are summarized in the Best Fits area of the Model Output window. The models in the Best Fits list are ordered from best at the top to worst at the bottom. The fit between the two curves is computed such that 100 means a perfect fit, and 0 indicates a poor fit (that is, the model output has the same fit to the measured output as the mean of the measured output).
In this example, the output of the models matches the validation data output, which indicates that the models seem to capture the main system dynamics and that linear modeling is sufficient.
2.3 Estimating Linear Models
Strategy for Estimating Accurate Models
In this portion of the tutorial, you get accurate parametric models by performing the following tasks:
(1) Identifying initial model orders and delays from your data using a simple, polynomial model structure (ARX).
(2) Exploring more complex model structures with orders and delays close to the initial values you found.
Estimating Possible Model Orders
To identify black-box models, you must specify the model order. However, how can you tell what model orders to specify for your black-box models? To answer this question, you can estimate simple polynomial (ARX) models for a range of orders and delays and compare the performance of these models. You choose the orders and delays that correspond to the best model fit as an initial guess for more accurate modeling using various model structures such as transfer function and state-space models.
About ARX Models. For a single-input/single-output system (SISO), the ARX model structure is:
How to Estimate Model Orders
1、In the System Identification app, select Estimate > Polynomial Models to open the Polynomial Models dialog box.
2、From the Structure list, select ARX: [na nb nk]. By default, this is already selected.
3、Edit the Orders field to try all combinations of poles, zeros, and delays, where each value is from 1 to 10:
[1:10 1:10 1:10]
4、Click Estimate to open the ARX Model Structure Selection window, which displays the model performance for each combination of model parameters.You use this plot to select the best-fit model
5、In the ARX Model Structure Selection window, click the red bar (corresponding to 15 on the horizontal axis), and click Insert. This selection inserts na=6, nb=9, and nk=2 into the Polynomial Models dialog box and performs the estimation.This action adds the model arx692 to the System Identification app and updates the plots to include the response of the model.
6、In the ARX Model Structure Selection window, click the third bar corresponding to 4 parameters on the horizontal axis (the lowest order that still gives a good fit), and click Insert.
7、Click Close to close the ARX Model Structure Selection window.
8、Click Close to close the Polynomial Models dialog box.
Identifying Transfer Function Models
In this portion of the tutorial, you estimate a transfer function model.
(a)About Transfer Function Models
The general transfer function model structure is:
Y(s), U(s) and E(s) represent the Laplace transforms of the output, input and error, respectively. num(s) and den(s) represent the numerator and denominator polynomials that define the relationship between the input and the output. The roots of the denominator polynomial are referred to as the model poles. The roots of the numerator polynomial are referred to as the model zeros.
You must specify the number of poles and zeros to estimate a transfer function model. The System Identification Toolbox product estimates the numerator and denominator polynomials, and input/output delays from the data.
The transfer function model structure is a good choice for quick estimation because it requires that you specify only 2 parameters to get started: np is the number of poles and nz is the number of zeros.
(b)How to Estimate Transfer Function Models
1、In the System Identification app, select Estimate > Transfer Function Models to open the Transfer Functions dialog box.
2、In the Transfer Functions dialog box, specify the following options: Number of poles — Leave the default value 2 to specify a second order function, for two poles. Number of zeros — Leave the default value 1. Continuous-time — Leave this checked.
3、Click I/O Delay to expand the input/output delay specification area.
By estimating ARX models for different order combinations, as described in Estimating Possible Model Orders, you identified a 3 sample delay (nk = 3). This delay translates to a continuous-time delay of (nk-1)*Ts , which is equal to 0.16 seconds.
Specify Delay as 0.16 seconds. Leave Fixed checked.
Use the default Estimation Options. By default, the app assigns the name tf1 to the model. The dialog box should look like this.
4、Click Estimate to add a transfer function model called tf1 to the System Identification app. You can view the output of the estimation of the transfer function model in comparison with the estimations of other models, in the Model output window.
5、Click Close to close the Transfer Functions dialog box.
(c)Learn More
To learn more about identifying transfer function models, see Transfer Function Models.
Identifying State-Space Models
In this portion of the tutorial, you estimate a state-space model.
(a)About State-Space Models
The general state-space model structure (innovation form) is:
You must specify a single integer as the model order (dimension of the state vector) to estimate a state-space model. The System Identification Toolbox product estimates the state-space matrices A, B, C, D, and K from the data.
The state-space model structure is a good choice for quick estimation because it requires that you specify only the number of states (which equals the number of poles). You can optionally also specify the delays and feedthrough behavior.
(b)How to Estimate State-Space Models
1、In the System Identification app, select Estimate > State Space Models to open the State Space Models dialog box.
2、In the Specify value field, specify the model order. Type 6 to create a sixth-order state-space model.
This choice is based on the fact that the best-fit ARX model has six poles.
3、Click Estimation Options to expand the estimation options area.
4、Change Focus to Simulation to optimize the model to use for output simulation.
The State Space Models dialog box looks like the following figure.
5、Click Estimate to add a state-space model called ss1 to the System Identification app.
You can view the output of the estimation of the state-space model in comparison with the estimations of other models, in the Model output window.
6、Click Close to close the State Space Models dialog box.
(c)Learn More
To learn more about identifying state-space models, see State-Space Models.
Identifying ARMAX Models
In this portion of the tutorial, you estimate an ARMAX input-output polynomial model.
(a)About ARMAX Models
For a single-input/single-output system (SISO), the ARMAX polynomial model structure is:
You must specify the model orders to estimate ARMAX models. The System Identification Toolbox product estimates the model parameters from the data.
(b)How to Estimate ARMAX Models
1、In the System Identification app , select Estimate > Polynomial Models to open the Polynomial Models dialog box.
2、From the Structure list, select ARMAX: [na nb nc nk] to estimate an ARMAX model.
3、In the Orders field, set the orders na, nb, nc, and nk to the following values:
[2 2 2 2]
The app assigns the name to the model amx2222, by default, visible in the Name field.
4、Click Estimate to add the ARMAX model to the System Identification app.
5、Repeat steps 3 and 4 using higher Orders 3 3 2 2. These orders result in a model that fits the data almost as well as the higher order ARX model arx692.
6、Click Close to close the Polynomial Models dialog box.
(c)Learn More
To learn more about identifying input-output polynomial models, such as ARMAX, see Input-Output Polynomial Models.
Choosing the Best Model
You can compare models to choose the model with the best performance.
You must have already estimated the models, as described in Estimating Linear Models.
Examining the Model Output. Examine the model output plot to see how well the model output matches the measured output in the validation data set. A good model is the simplest model that best describes the dynamics and successfully simulates or predicts the output for different inputs. Models are listed by name in the Best Fits area of the Model Output plot. Note that one of the simpler models, amx3322, produced a similar fit as the highest-order model you created, arx692.
2.4 Viewing Model Parameters
Viewing Model Parameter Values
You can view the numerical parameter values for each estimated model.
To view the parameter values of the model amx3322, right-click the model icon in the System Identification app. The Data/model Info dialog box opens.
The noneditable area of the Data/model Info dialog box lists the parameter values correspond to the following difference equation for your system:
The coefficient of u(t-2) is not significantly different from zero. This lack of difference explains why delay values of both 2 and 3 give good results.
Parameter values appear in the following format:
The parameters appear in the ARMAX model structure, as follows:
which corresponds to this general difference equation:
y(t) represents the output at time t, u(t) represents the input at time t, na is the number of poles for the dynamic model, nb is the number of zeros plus 1, nc is the number of poles for the disturbance model, nk is the number of samples before the input affects output of the system (called the delay or dead time of the model), and e(t) is the white-noise disturbance.
Viewing Parameter Uncertainties
You can view parameter uncertainties of estimated models.
To view parameter uncertainties, click Present in the Data/model Info dialog box, and view the model information at the MATLAB prompt. The 1-standard deviation uncertainty for the model parameters is in parentheses next to each parameter value.
2.5 Exporting the Model to the MATLAB Workspace
The models you create in the System Identification app are not automatically available in the MATLAB workspace. To make a model available to other toolboxes, Simulink®, and System Identification Toolbox commands, you must export your model from the System Identification app to the MATLAB workspace. For example, if the model is a plant that requires a controller, you can import the model from the MATLAB workspace into the Control System Toolbox™ product.
To export the amx3322 model, drag it to the To Workspace rectangle in the System Identification app. Alternatively, click Export in the Data/model Info dialog box.
After the model is in the MATLAB workspace, you can perform other operations on the model. For example, if you have the Control System Toolbox product installed, you might transform the model to a state-space object using:
ss_model=ss(amx3322)
2.6 Exporting the Model to the Linear System Analyzer
If you have the Control System Toolbox product installed, the To Linear System Analyzer rectangle appears in the System Identification app.
The Linear System Analyzer is a graphical user interface for viewing and manipulating the response plots of linear models. It displays the following plots:
Step- and impulse-response
Bode, Nyquist, and Nichols
Frequency-response singular values
Pole/zero
Response to general input signals
Unforced response starting from given initial states (only for state-space models)
To plot a model in the Linear System Analyzer, drag and drop the model icon to the To Linear System Analyzer rectangle in the System Identification app. Alternatively, click Show in Linear System Analyzer in the Data/model Info dialog box.
For more information about working with plots in the Linear System Analyzer, see Linear System Analyzer Overview (Control System Toolbox).