Identify Low-Order Transfer Functions (Process Models) Using System Identification App - MATLAB and Simulink
Identify Low-Order Transfer Functions (Process Models) Using System Identification App - MATLAB and Simulink
Objectives
Estimate and validate simple, continuoustime transfer functions from singleinput/singleoutput (SISO) data to
find the one that best describes the system dynamics.
After completing this tutorial, you will be able to accomplish the following tasks using the System Identification
app :
• Import data objects from the MATLAB® workspace into the app.
• Plot and process the data.
• Estimate and validate loworder, continuoustime models from the data.
• Export models to the MATLAB workspace.
• Simulate the model using Simulink ® software.
Note: This tutorial uses timedomain data to demonstrate how you can estimate linear models. The same workflow
applies to fitting frequencydomain data.
Data Description
This tutorial uses the data file proc_data.mat, which contains 200 samples of simulated singleinput/single
output (SISO) timedomain data. The input is a random binary signal that oscillates between 1 and 1. White noise
(corresponding to a load disturbance) is added to the input with a standard deviation of 0.2, which results in a
signaltonoise ratio of about 20 dB. This data is simulated using a secondorder system with underdamped modes
(complex poles) and a peak response at 1 rad/s:
1
G(s) = e−2s
1+0.2s+s2
You can specify different process model structures by varying the number of poles, adding an integrator, or
including a time delay or a zero. The highest process model order you can specify in this toolbox is three, and the
poles can be real or complex (underdamped modes).
In general, a linear system is characterized by a transfer function G, which is an operator that takes the input u to
the output y:
y = Gu
For a continuoustime system, G relates the Laplace transforms of the input U(s) and the output Y(s), as follows:
http://www.mathworks.com/help/ident/gs/identifylowordertransferfunctionsprocessmodelsusingthegui.html 1/24
3/6/2016 Identify LowOrder Transfer Functions (Process Models) Using System Identification App MATLAB & Simulink
For example, the following model structure is a firstorder, continuoustime model, where K is the static gain, Tp1
is a time constant, and Td is the inputtooutput delay:
−sT
K d
G(s) = 1+sT
e
p1
load proc_data
This command loads the data into the MATLAB workspace as the data object z. For more information about
iddata objects, see the corresponding reference page.
systemIdentification
http://www.mathworks.com/help/ident/gs/identifylowordertransferfunctionsprocessmodelsusingthegui.html 2/24
3/6/2016 Identify LowOrder Transfer Functions (Process Models) Using System Identification App MATLAB & Simulink
You must have already loaded the sample data into MATLAB, as described in Loading Data into the MATLAB
Workspace, and opened the app, as described in Opening the System Identification App.
If you have not performed these steps, click here to complete them.
• Object — Enter z as the name of the MATLAB variable that is the timedomain data object. Press Enter.
• Data name — Use the default name z, which is the same as the name of the data object you are
importing. This name labels the data in the System Identification app after the import operation is
completed.
• Starting time — Enter 0 as the starting time. This value designates the starting value of the time axis on
time plots.
http://www.mathworks.com/help/ident/gs/identifylowordertransferfunctionsprocessmodelsusingthegui.html 3/24
3/6/2016 Identify LowOrder Transfer Functions (Process Models) Using System Identification App MATLAB & Simulink
• Sample time — Enter 1 as the time between successive samples in seconds. This value represents the
actual sample time in the experiment.
The Import Data dialog box now resembles the following figure.
3. Click Import to add the data to the System Identification app. The app adds an icon to represent the data.
http://www.mathworks.com/help/ident/gs/identifylowordertransferfunctionsprocessmodelsusingthegui.html 4/24
3/6/2016 Identify LowOrder Transfer Functions (Process Models) Using System Identification App MATLAB & Simulink
• Split the data into two parts. You use one part of the data for model estimation, and the other part of the data
for model validation.
The reason you subtract the mean values from each signal is because, typically, you build linear models that
describe the responses for deviations from a physical equilibrium. With steadystate data, it is reasonable to
assume that the mean levels of the signals correspond to such an equilibrium. Thus, you can seek models around
zero without modeling the absolute equilibrium levels in physical units.
You must have already imported data into the System Identification app, as described in Importing Data Objects
into the System Identification App.
If you have not performed this step, click here to complete it.
1. Select the Time plot check box to open the Time Plot window.
The bottom axes show the input data—a random binary sequence, and the top axes show the output data.
The next two steps demonstrate how to modify the axis limits in the plot.
2. To modify the verticalaxis limits for the input data, select Options > Set axes limits in the Time Plot figure
window.
3. In the Limits for Time Plot dialog box, set the new vertical axis limit of the input data channel u1 to [1.5 1.5].
Click Apply and Close.
http://www.mathworks.com/help/ident/gs/identifylowordertransferfunctionsprocessmodelsusingthegui.html 5/24
3/6/2016 Identify LowOrder Transfer Functions (Process Models) Using System Identification App MATLAB & Simulink
Note: The other two fields in the Limits for Time Plot dialog box, Time and y1, let you set the axis limits for the
time axis and the output channel axis, respectively. You can also specify each axis to be logarithmic or linear by
selecting the corresponding option.
4. In the System Identification app , select <Preprocess > Quick start to perform the following four actions:
http://www.mathworks.com/help/ident/gs/identifylowordertransferfunctionsprocessmodelsusingthegui.html 6/24
3/6/2016 Identify LowOrder Transfer Functions (Process Models) Using System Identification App MATLAB & Simulink
Learn More. For information about supported data processing operations, such as resampling and filtering the
data, see Preprocess Data.
K −T s
d
G(s) = ( ) e
1+2ξT s+T 2s2
w w
You must have already processed the data for estimation, as described in Plotting and Processing Data.
If you have not performed this step, click here to complete it.
1. In the System Identification app, select Estimate > Process models to open the Process Models dialog box.
2. In the Model Transfer Function area of the Process Models dialog box, specify the following options:
http://www.mathworks.com/help/ident/gs/identifylowordertransferfunctionsprocessmodelsusingthegui.html 7/24
3/6/2016 Identify LowOrder Transfer Functions (Process Models) Using System Identification App MATLAB & Simulink
3. The Parameter area of the Process Models dialog box now shows four active parameters: K, Tw, Zeta, and
Td. In the Initial Guess area, keep the default Auto‐selected option to calculate the initial parameter values
during the estimation. The Initial Guess column in the Parameter table displays Auto.
4. Keep the default Bounds values, which specify the minimum and maximum values of each parameter.
Tip If you know the range of possible values for a parameter, you can type these values into the corresponding
Bounds fields to help the estimation algorithm.
• Disturbance Model — None means that the algorithm does not estimate the noise model. This option also
sets the Focus to Simulation.
• Focus — Simulation means that the estimation algorithm does not use the noise model to weigh the
relative importance of how closely to fit the data in various frequency ranges. Instead, the algorithm uses
the input spectrum in a particular frequency range to weigh the relative importance of the fit in that
frequency range.
Tip The Simulation setting is optimized for identifying models that you plan to use for output simulation. If
you plan to use your model for output prediction or control applications, or to improve parameter estimates
using a noise model, select Prediction.
• Initial condition — Auto means that the algorithm analyzes the data and chooses the optimum method
for handling the initial state of the system. If you get poor results, you might try setting a specific method
for handling initial states, rather than choosing it automatically.
• Covariance — Estimate means that the algorithm computes parameter uncertainties that display as
model confidence regions on plots.
The app assigns a name to the model, shown in the Name field (located at the bottom of the dialog box). By
default, the name is the acronym P2DU, which indicates two poles (P2), a delay (D), and underdamped modes
(U).
http://www.mathworks.com/help/ident/gs/identifylowordertransferfunctionsprocessmodelsusingthegui.html 8/24
3/6/2016 Identify LowOrder Transfer Functions (Process Models) Using System Identification App MATLAB & Simulink
6. Click Estimate to add the model P2DU to the System Identification app.
If you know the approximate value of a parameter, you can help the estimation algorithm by entering an initial
value in the Initial Guess column. In this case, keep the Known check box cleared to allow the estimation to
finetune this initial guess.
For example, to fix the timedelay value Td at 2s, you can type this value into Value field of the Parameter table
in the Process Models dialog box and select the corresponding Known check box.
http://www.mathworks.com/help/ident/gs/identifylowordertransferfunctionsprocessmodelsusingthegui.html 9/24
3/6/2016 Identify LowOrder Transfer Functions (Process Models) Using System Identification App MATLAB & Simulink
• Comparison of the model output and the measured output on a time plot
• Autocorrelation of the output residuals, and crosscorrelation of the input and the output residuals
You must have already estimated the model, as described in Estimating a SecondOrder Transfer Function Using
Default Settings.
If you have not performed this step, click here to complete it.
Examining Model Output. You can use the modeloutput plot to check 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.
To generate the modeloutput plot, select the Model output check box in the System Identification app. If the plot
is empty, click the model icon in the System Identification app window to display the model on the plot.
http://www.mathworks.com/help/ident/gs/identifylowordertransferfunctionsprocessmodelsusingthegui.html 10/24
3/6/2016 Identify LowOrder Transfer Functions (Process Models) Using System Identification App MATLAB & Simulink
The System Identification Toolbox™ software uses input validation data as input to the model, and plots the
simulated output on top of the output validation data. The preceding plot shows that the model output agrees well
with the validationdata output.
The Best Fits area of the Model Output plot shows the agreement (in percent) between the model output and the
validationdata output.
Recall that the data was simulated using the following secondorder system with underdamped modes (complex
poles), as described in Data Description, and has a peak response at 1 rad/s:
1
G(s) = e−2s
1+0.2s+s2
Because the data includes noise at the input during the simulation, the estimated model cannot exactly reproduce
the model used to simulate the data.
Examining Model Residuals. You can validate a model by checking the behavior of its residuals.
To generate a Residual Analysis plot, select the Model resids check box in the System Identification app.
http://www.mathworks.com/help/ident/gs/identifylowordertransferfunctionsprocessmodelsusingthegui.html 11/24
3/6/2016 Identify LowOrder Transfer Functions (Process Models) Using System Identification App MATLAB & Simulink
The top axes show the autocorrelation of residuals for the output (whiteness test). The horizontal scale is the
number of lags, which is the time difference (in samples) between the signals at which the correlation is
estimated. Any fluctuations within the confidence interval are considered to be insignificant. A good model should
have a residual autocorrelation function within the confidence interval, indicating that the residuals are
uncorrelated. However, in this example, the residuals appear to be correlated, which is natural because the noise
model is used to make the residuals white.
The bottom axes show the crosscorrelation of the residuals with the input. A good model should have residuals
uncorrelated with past inputs (independence test). Evidence of correlation indicates that the model does not
describe how a portion of the output relates to the corresponding input. For example, when there is a peak outside
the confidence interval for lag k, this means that the contribution to the output y(t) that originates from the input
u(tk) is not properly described by the model. In this example, there is no correlation between the residuals and the
inputs.
Thus, residual analysis indicates that this model is good, but that there might be a need for a noise model.
You must have already estimated the model, as described in Estimating a SecondOrder Transfer Function Using
Default Settings.
If you have not performed this step, click here to complete it.
1. If the Process Models dialog box is not open, select Estimate > Process Models in the System Identification
app. This action opens the Process Models dialog box.
http://www.mathworks.com/help/ident/gs/identifylowordertransferfunctionsprocessmodelsusingthegui.html 12/24
3/6/2016 Identify LowOrder Transfer Functions (Process Models) Using System Identification App MATLAB & Simulink
• Under Poles, select 2 and Underdamped. This selection updates the Model Transfer Function to a second
order model structure that can contain complex poles. Make sure that the Zero and Integrator check
boxes are cleared to exclude a zero and an integrator (selfregulating ) from the model.
H = DC e
where and D are firstorder polynomials, and e is white noise.
This action specifies the Focus as Prediction, which improves accuracy in the frequency range where
the noise level is low. For example, if there is more noise at high frequencies, the algorithm assigns less
importance to accurately fitting the highfrequency portions of the data.
• Name — Edit the model name to P2DUe1 to generate a model with a unique name in the System
Identification app.
3. Click Estimate.
4. In the Process Models dialog box, set the Disturbance Model to Order 2 to estimate a secondorder noise
model.
5. Edit the Name field to P2DUe2 to generate a model with a unique name in the System Identification app.
6. Click Estimate.
http://www.mathworks.com/help/ident/gs/identifylowordertransferfunctionsprocessmodelsusingthegui.html 13/24
3/6/2016 Identify LowOrder Transfer Functions (Process Models) Using System Identification App MATLAB & Simulink
In this portion of the tutorial, you evaluate model performance using the Model Output and the Residual Analysis
plots.
You must have already estimated the models, as described in Estimating a SecondOrder Transfer Function Using
Default Settings and Estimating a SecondOrder Process Model with Complex Poles.
If you have not performed these steps, click here to complete them.
Comparing the Model Output Plots. To generate the Model Output plot, select the Model output check box in
the System Identification app. If the plot is empty or a model output does not appear on the plot, click the model
icons in the System Identification app window to display these models on the plot.
The following Model Output plot shows the simulated model output, by default. The simulated response of the
models is approximately the same for models with and without noise. Thus, including the noise model does not
affect the simulated output.
To view the predicted model output, select Options > 5 step ahead predicted output in the Model Output plot
window.
The following Model Output plot shows that the predicted model output of P2DUe2 (with a secondorder noise
model) is better than the predicted output of the other two models (without noise and with a firstorder noise model,
respectively).
http://www.mathworks.com/help/ident/gs/identifylowordertransferfunctionsprocessmodelsusingthegui.html 14/24
3/6/2016 Identify LowOrder Transfer Functions (Process Models) Using System Identification App MATLAB & Simulink
Comparing the Residual Analysis Plots. To generate the Residual Analysis plot, select the Model resids
check box in the System Identification app. If the plot is empty, click the model icons in the System Identification
app window to display these models on the plot.
P2DUe2 falls well within the confidence bounds on the Residual Analysis plot.
To view residuals for P2DUe2 only, remove models P2DU and P2DUe1 from the Residual Analysis plot by clicking
the corresponding icons in the System Identification app.
http://www.mathworks.com/help/ident/gs/identifylowordertransferfunctionsprocessmodelsusingthegui.html 15/24
3/6/2016 Identify LowOrder Transfer Functions (Process Models) Using System Identification App MATLAB & Simulink
The whiteness test for P2DUe2 shows that the residuals are uncorrelated, and the independence test shows no
correlation between the residuals and the inputs. These tests indicate that P2DUe2 is a good model.
http://www.mathworks.com/help/ident/gs/identifylowordertransferfunctionsprocessmodelsusingthegui.html 16/24
3/6/2016 Identify LowOrder Transfer Functions (Process Models) Using System Identification App MATLAB & Simulink
The noneditable area of the dialog box lists the model coefficients that correspond to the following model
structure:
K −T s
G(s) = ( ) e d
22
1+2ξT s+T s
w w
The coefficients agree with the model used to simulate the data:
1
G(s) = e−2s
1+0.2s+s2
http://www.mathworks.com/help/ident/gs/identifylowordertransferfunctionsprocessmodelsusingthegui.html 17/24
3/6/2016 Identify LowOrder Transfer Functions (Process Models) Using System Identification App MATLAB & Simulink
P2DUe2 also includes an additive noise term, where H is a secondorder ARMA model and e is white noise:
H = DC e
The software displays the noise model H as a ratio of two polynomials, C(s)/D(s), where:
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 the System Identification Toolbox
commands, you must export your model from the System Identification app to the MATLAB workspace.
To export the P2DUe2 model, drag the model icon to the To Workspace rectangle in the System Identification app.
Alternatively, click Export in the Data/model Info dialog box. The model now appears in the MATLAB Workspace
browser.
To perform the steps in this tutorial, Simulink must be installed on your computer.
• Load the data set, as described in Loading Data into the MATLAB Workspace.
• Estimate the secondorder process model, as described in Estimating a SecondOrder Process Model with
Complex Poles.
• Export the model to the MATLAB workspace, as described in Exporting the Model to the MATLAB Workspace.
If you have not performed these steps, click here to complete them. Then, drag the z and the P2DUe2 icons to the
To Workspace rectangle in the System Identification app. Alternatively, click Export in the Data/model Info dialog
box. The data and the model now appear in the MATLAB Workspace browser.
Learn More. For more information about representing data signals for system identification, see Representing
Data in MATLAB Workspace.
2. In the Simulink start page, click Blank Model. Then click Create Model to open a new model window.
3. In the Simulink model window, click to open the Library Browser. In the Library Browser, select the
System Identification Toolbox library. The right side of the window displays blocks specific to the System
Identification Toolbox product.
Tip Alternatively, to access the System Identification block library, type slident in the MATLAB Command
Window.
4. Drag the following System Identification Toolbox blocks to the new model window:
http://www.mathworks.com/help/ident/gs/identifylowordertransferfunctionsprocessmodelsusingthegui.html 19/24
3/6/2016 Identify LowOrder Transfer Functions (Process Models) Using System Identification App MATLAB & Simulink
5. In the Simulink Library Browser, select the Simulink > Sinks library, and drag the Scope block to the new
model window.
6. In the Simulink model window, connect the blocks to resembles the following figure.
Next, you configure these blocks to get data from the MATLAB workspace and set the simulation time interval
and duration.
z_input
This variable is the data object in the MATLAB workspace that contains the input data.
http://www.mathworks.com/help/ident/gs/identifylowordertransferfunctionsprocessmodelsusingthegui.html 20/24
3/6/2016 Identify LowOrder Transfer Functions (Process Models) Using System Identification App MATLAB & Simulink
Tip As a shortcut, you can drag and drop the variable name from the MATLAB Workspace browser to the IDDATA
object field.
Click OK.
4. Doubleclick the Idmodel block to open the Function Block Parameters: Idmodel dialog box.
a. Type the following variable name in the Model variable field:
P2DUe2
This variable represents the name of the model in the MATLAB workspace.
b. Clear the Add noise check box to exclude noise from the simulation. Click OK.
When Add noise is selected, Simulink derives the noise amplitude from the NoiseVariance property of
the model and adds noise to the model accordingly. The simulation propagates this noise according to the
noise model H that was estimated with the system dynamics:
H = DC e
http://www.mathworks.com/help/ident/gs/identifylowordertransferfunctionsprocessmodelsusingthegui.html 21/24
3/6/2016 Identify LowOrder Transfer Functions (Process Models) Using System Identification App MATLAB & Simulink
Click OK.
5. Doubleclick the Iddata Sink block to open the Sink Block Parameters: Iddata Sink dialog box. Type the
following variable name in the IDDATA Name field:
z_sim_out
6. Type 1 in the Sample Time (sec.) field to set the sample time of the output data to match the sample time of
the input data.
http://www.mathworks.com/help/ident/gs/identifylowordertransferfunctionsprocessmodelsusingthegui.html 22/24
3/6/2016 Identify LowOrder Transfer Functions (Process Models) Using System Identification App MATLAB & Simulink
Click OK.
The resulting change to the Simulink model is shown in the following figure.
http://www.mathworks.com/help/ident/gs/identifylowordertransferfunctionsprocessmodelsusingthegui.html 23/24
3/6/2016 Identify LowOrder Transfer Functions (Process Models) Using System Identification App MATLAB & Simulink
3. In the MATLAB Workspace browser, notice the variable z_sim_out that stores the model output as an
iddata object. You specified this variable name when you configured the Iddata Sink block.
This variable stores the simulated output of the model, and it is now available for further processing and
exploration.
http://www.mathworks.com/help/ident/gs/identifylowordertransferfunctionsprocessmodelsusingthegui.html 24/24