System Identification Toolbox™ 7 User’s Guide Lennart Ljung
How to Contact The MathWorks Web Newsgroup www.mathworks.com/contact_TS.html Technical Support www.mathworks.com comp.soft-sys.matlab suggest@mathworks.com bugs@mathworks.com doc@mathworks.com service@mathworks.com info@mathworks.com Product enhancement suggestions Bug reports Documentation error reports Order status, license renewals, passcodes Sales, pricing, and general information 508-647-7000 (Phone) 508-647-7001 (Fax) The MathWorks, Inc.
Revision History April 1988 July 1991 May 1995 November 2000 April 2001 July 2002 June 2004 March 2005 September 2005 March 2006 September 2006 March 2007 September 2007 March 2008 October 2008 First printing Second printing Third printing Fourth printing Fifth printing Online only Sixth printing Online only Seventh printing Online only Online only Online only Online only Online only Online only Revised for Version 5.0 (Release 12) Revised for Version 5.0.2 (Release 13) Revised for Version 6.0.
About the Developers About the Developers System Identification Toolbox™ software is developed in association with the following leading researchers in the system identification field: Lennart Ljung. Professor Lennart Ljung is with the Department of Electrical Engineering at Linköping University in Sweden. He is a recognized leader in system identification and has published numerous papers and books in this area. Qinghua Zhang. Dr.
About the Developers
Contents Data Processing 1 Ways to Process Data for System Identification . . . . . . . 1-2 Importing Data into the MATLAB Workspace . . . . . . . . Types of Data You Can Model . . . . . . . . . . . . . . . . . . . . . . . Support for Data with Uniform and Nonuniform Sampling Intervals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Importing Time-Domain Data into MATLAB . . . . . . . . . . . Importing Time-Series Data into MATLAB . . . . . . . . . . . .
viii Contents Creating Multiexperiment Data at the Command Line . . . Subreferencing iddata Objects . . . . . . . . . . . . . . . . . . . . . . . Modifying Time and Frequency Vectors . . . . . . . . . . . . . . . Naming, Adding, and Removing Data Channels . . . . . . . . . Concatenating iddata Objects . . . . . . . . . . . . . . . . . . . . . . . 1-53 1-55 1-59 1-63 1-65 Representing Frequency-Response Data Using idfrd Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
..... 1-98 Resampling Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . What Is Resampling? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Resampling Data Using the GUI . . . . . . . . . . . . . . . . . . . . . Resampling Data at the Command Line . . . . . . . . . . . . . . . Resampling Data Without Aliasing Effects . . . . . . . . . . . . . See Also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Supported Models for Time- and Frequency-Domain Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Supported Models for Time-Domain Data . . . . . . . . . . . . . . Supported Models for Frequency-Domain Data . . . . . . . . . 2-4 2-4 2-5 Supported Continuous-Time and Discrete-Time Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7 Commands for Model Estimation . . . . . . . . . . . . . . . . . . . .
.............. 3-11 Identifying Impulse-Response Models . . . . . . . . . . . . . . . What Is Time-Domain Correlation Analysis? . . . . . . . . . . . Data Supported by Correlation Analysis . . . . . . . . . . . . . . . How to Estimate Correlation Models Using the GUI . . . . . How to Estimate Correlation Models at the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How to Compute Response Values . . . . . . . . . . . . . . . . . . . .
Supported State-Space Parameterizations . . . . . . . . . . . . . Preliminary Step – Estimating State-Space Model Orders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How to Estimate State-Space Models in the GUI . . . . . . . . How to Estimate State-Space Models at the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How to Estimate Free-Parameterization State-Space Models . . . . . . . . . . . . . . . . . . . . . . . . . . .
Subreferencing Model Objects . . . . . . . . . . . . . . . . . . . . . . What Is Subreferencing? . . . . . . . . . . . . . . . . . . . . . . . . . . . . Limitation on Supported Models . . . . . . . . . . . . . . . . . . . . . Subreferencing Specific Measured Channels . . . . . . . . . . . Subreferencing Measured and Noise Models . . . . . . . . . . . Treating Noise Channels as Measured Inputs . . . . . . . . . . 3-119 3-119 3-119 3-119 3-120 3-122 Concatenating Model Objects . . . . . . . . . . . . . . .
Nonlinearity Estimators for Hammerstein-Wiener Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How to Estimate Hammerstein-Wiener Models in the GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How to Estimate Hammerstein-Wiener Models at the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Supported Nonlinearity Estimators . . . . . . . . . . . . . . . . . Types of Nonlinearity Estimators . . . . . .
ODE Parameter Estimation (Grey-Box Modeling) 5 Supported Grey-Box Models . . . . . . . . . . . . . . . . . . . . . . . . 5-2 Data Supported by Grey-Box Models . . . . . . . . . . . . . . . . 5-3 Choosing idgrey or idnlgrey Model Object . . . . . . . . . . . 5-4 Estimating Linear Grey-Box Models . . . . . . . . . . . . . . . . . Specifying the Linear Grey-Box Model Structure . . . . . . . . Example – Representing a Grey-Box Model in an M-File . .
How to Estimate Time-Series Power Spectra Using the GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How to Estimate Time-Series Power Spectra at the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4 6-5 Estimating AR and ARMA Models . . . . . . . . . . . . . . . . . . . Definition of AR and ARMA Models . . . . . . . . . . . . . . . . . . . Estimating Polynomial Time-Series Models in the GUI . . .
Model Analysis 8 Overview of Model Validation and Plots . . . . . . . . . . . . . When to Validate Models . . . . . . . . . . . . . . . . . . . . . . . . . . . Ways to Validate Models . . . . . . . . . . . . . . . . . . . . . . . . . . . Data for Validating Models . . . . . . . . . . . . . . . . . . . . . . . . . Supported Model Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Plotting Models in the GUI . . . . . . . . . . . . . . . . . . . . . . . . . . Getting Advice About Models . . . . .
What Is Frequency Response? . . . . . . . . . . . . . . . . . . . . . . . How Frequency Response Helps to Validate Models . . . . . What Does a Frequency-Response Plot Show? . . . . . . . . . . How to Plot Bode Plots Using the GUI . . . . . . . . . . . . . . . . How to Plot Bode and Nyquist Plots at the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-32 8-33 8-34 8-35 Creating Noise-Spectrum Plots . . . . . . . . . . . . . . . . . . . . .
Computing Model Uncertainty . . . . . . . . . . . . . . . . . . . . . . Why Analyze Model Uncertainty? . . . . . . . . . . . . . . . . . . . . What Is Model Covariance? . . . . . . . . . . . . . . . . . . . . . . . . . Viewing Model Uncertainty Information . . . . . . . . . . . . . . . 8-64 8-64 8-64 8-65 Troubleshooting Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . About Troubleshooting Models . . . . . . . . . . . . . . . . . . . . . . . Model Order Is Too High or Too Low . . . . . . .
Using Identified Models in Control Design 10 Using Models with Control System Toolbox Software . . How Control System Toolbox Software Works with Identified Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using balred to Reduce Model Order . . . . . . . . . . . . . . . . . . Compensator Design Using Control System Toolbox Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Converting Models to LTI Objects . . . . . . . . . . . . . . . . . . . .
Using the System Identification Tool GUI 12 Steps for Using the System Identification Tool GUI . . . 12-2 Starting and Managing GUI Sessions . . . . . . . . . . . . . . . . What Is a System Identification Tool Session? . . . . . . . . . . Starting a New Session in the GUI . . . . . . . . . . . . . . . . . . . Description of the System Identification Tool Window . . . . Opening a Saved Session . . . . . . . . . . . . . . . . . . . . . . . . . . . Saving, Merging, and Closing Sessions . . . . . . . . . . .
Index xxii Contents
1 Data Processing • “Ways to Process Data for System Identification” on page 1-2 • “Importing Data into the MATLAB Workspace” on page 1-5 • “Representing Data in the GUI” on page 1-13 • “Representing Time- and Frequency-Domain Data Using iddata Objects” on page 1-47 • “Representing Frequency-Response Data Using idfrd Objects” on page 1-67 • “Analyzing Data Quality Using Plots” on page 1-75 • “Getting Advice About Your Data” on page 1-84 • “Selecting Subsets of Data” on page 1-86 • “Handling Missing Data and
1 Data Processing Ways to Process Data for System Identification The following tasks help to prepare your data for identifying models from data: Import data into the MATLAB workspace Before you can begin identifying models, you must import your data into the MATLAB® workspace. You can import the data from external data files, create data by simulation, or manually create data arrays at the command line.
Ways to Process Data for System Identification Plot and analyze data You can analyze your data by doing either of the following: • Plotting data to examine both time- and frequency-domain behavior. See “Analyzing Data Quality Using Plots” on page 1-75. • Using the advice command to analyze the data for the presence of constant offsets and trends, delay, feedback, and signal excitation levels. See “Getting Advice About Your Data” on page 1-84.
1 Data Processing To learn more about selecting data, see “Selecting Subsets of Data” on page 1-86. Combine data from multiple experiments You can combine data from multiple experiments into a single data set. The model you estimate from a multiple-experiment data set describes the average system that represents these experiments.
Importing Data into the MATLAB® Workspace Importing Data into the MATLAB Workspace In this section...
1 Data Processing Note If your data is complex valued, see “Manipulating Complex-Valued Data” on page 1-131 for information about supported operations for complex data. Support for Data with Uniform and Nonuniform Sampling Intervals A sampling interval is the time between successive data samples. The System Identification Toolbox product provides limited support for nonuniformly sampled data.
Importing Data into the MATLAB® Workspace For a data set with Ny outputs and NT samples (measurements), the output is an NT-by-Ny matrix. • Sampling time interval If you are working with uniformly sampled data, use the actual sampling interval from your experiment. Each data value is assigned a sample time, which is calculated from the start time and the sampling interval.
1 Data Processing - If you are working with uniformly sampled data, use the actual sampling interval in your experiment. Each data value is assigned a sample time, which is calculated from the start time and the sampling interval. If you are working with nonuniformly sampled data at the command line, you can specify a vector of time instants using the iddata SamplingInstants property, as described in “Constructing an iddata Object for Time-Domain Data” on page 1-48.
Importing Data into the MATLAB® Workspace In the context of numerical computations, continuous equations are replaced by their discretized equivalents to handle discrete data values. For a discrete-time system with a sampling interval T, the frequency-domain output Y(eiw) and input U(eiw) is the time-discrete Fourier transform (TDFT): N Y (eiwT ) = T ∑ y(kT ) e−iwkT k=1 In this example, k = 1,2,...,N, where N is the number of samples in the sequence. Note This form only discretizes the time.
1 Data Processing • Output data - For single-input/single-output (SISO) data, the output must be a column vector. - For a data set with Ny outputs and Nf frequencies, the output is an Nf-by-Ny matrix. • Frequency values Must be a column vector. For more information about importing data into the MATLAB workspace, see the MATLAB documentation. After you import data, you can import it into the System Identification Tool GUI or create a data object for working at the command line.
Importing Data into the MATLAB® Workspace For a continuous-time system, the transfer function relates the Laplace transforms of the input U(s) and output Y(s): Y (s) = G(s)U (s) In this case, the frequency function G(iw) is the transfer function evaluated on the imaginary axis s=iw.
1 Data Processing You must import your frequency-response data into the MATLAB workspace as the following variables: • In System Identification Tool GUI or MATLAB Command Window, represent complex-valued G(eiw). For single-input single-output (SISO) systems, the frequency function is a column vector. For a data set with Nu inputs, Ny outputs, and Nf frequencies, the frequency function is an Ny-by-Nu-by-Nf array. • In System Identification Tool GUI only, represent amplitude G and phase shift ϕ = arg G .
Representing Data in the GUI Representing Data in the GUI In this section...
1 Data Processing To open the GUI, type the following command in the MATLAB Command Window: ident In the Import data list, select the type of data to import from the MATLAB workspace, as shown in the following figure. For an example of importing data into the System Identification Tool GUI, see the Getting Started documentation.
Representing Data in the GUI Importing Time-Domain Data into the GUI Before you can import time-domain data into the System Identification Tool GUI, you must import the data into the MATLAB workspace, as described in “Importing Time-Domain Data into MATLAB” on page 1-6. Note Your time-domain data must be sampled at equal time intervals. The input and output signals must have the same number of data samples.
1 Data Processing 3 Specify the following options: Note For time series, only import the output signal and enter [] for the input. • Input — Enter the MATLAB variable name (column vector or matrix) or a MATLAB expression that represents the input data. The expression must evaluate to a column vector or matrix. • Output — Enter the MATLAB variable name (column vector or matrix) or a MATLAB expression that represents the output data. The expression must evaluate to a column vector or matrix.
Representing Data in the GUI 4 (Optional) In the Data Information area, click More to expand the dialog box and enter the following settings: Input Properties • InterSample — This setting specifies the behavior of the input signals between samples when you transform the resulting models between discrete-time and continuous-time representations. – zoh (zero-order hold) maintains a piecewise-constant input signal between samples.
1 Data Processing • Output — Enter a string to specify the name of one or more output channels. Physical Units of Variables • Input — Enter a string to specify the input units. Tip When you have multiple inputs and outputs, enter a comma-separated list of Input and Output units corresponding to each channel. • Output — Enter a string to specify the output units. Notes — Enter comments about the experiment or the data.
Representing Data in the GUI 1 Type the following command in the MATLAB Command Window to open the GUI: ident 2 In the System Identification Tool window, select Import data > Freq. domain data. This action opens the Import Data dialog box. 3 Specify the following options: • Input — Enter the MATLAB variable name (column vector or matrix) or a MATLAB expression that represents the input data. The expression must evaluate to a column vector or matrix.
1 Data Processing • InterSample — This setting specifies the behavior of the input signals between samples when you transform the resulting models between discrete-time and continuous-time representations. – zoh (zero-order hold) maintains a piecewise-constant input signal between samples. – foh (first-order hold) maintains a piecewise-linear input signal between samples.
Representing Data in the GUI • Input — Enter a string to specify the input units. Tip When you have multiple inputs and outputs, enter a comma-separated list of Input and Output units corresponding to each channel. • Output — Enter a string to specify the output units. Notes — Enter comments about the experiment or the data. For example, you might enter the experiment name, date, and a description of experimental conditions. Models you estimate from this data inherit your data notes. 5 Click Import.
1 Data Processing ident 2 In the System Identification Tool window, select Import data > Freq. domain data. This action opens the Import Data dialog box. 3 In the Data Format for Signals list, select Freq. Function (Complex). 4 Specify the following options: • Freq. Func. — Enter the MATLAB variable name or a MATLAB expression that represents the complex frequency-response data G(eiw). • Frequency — Enter the MATLAB variable name of a vector or a MATLAB expression that represents the frequency.
Representing Data in the GUI Physical Units of Variables • Input — Enter a string to specify the input units. Tip When you have multiple inputs and outputs, enter a comma-separated list of Input and Output units corresponding to each channel. • Output — Enter a string to specify the output units. Notes — Enter comments about the experiment or the data. For example, you might enter the experiment name, date, and a description of experimental conditions.
1 Data Processing 4 Specify the following options: • Amplitude — Enter the MATLAB variable name or a MATLAB expression that represents the amplitude G . • Phase (deg) — Enter the MATLAB variable name or a MATLAB expression that represents the phase ϕ = arg G . • Frequency — Enter the MATLAB variable name of a vector or a MATLAB expression that represents the frequency. The expression must evaluate to a column vector.
Representing Data in the GUI Tip When you have multiple inputs and outputs, enter a comma-separated list of Input and Output units corresponding to each channel. • Output — Enter a string to specify the output units. Notes — Enter comments about the experiment or the data. For example, you might enter the experiment name, date, and a description of experimental conditions. Models you estimate from this data inherit your data notes. 6 Click Import.
1 Data Processing 1 Type the following command in the MATLAB Command Window to open the GUI: ident 2 In the System Identification Tool window, select Import data > Data object. This action opens the Import Data dialog box. IDDATA or IDFRD/FRD is already selected in the Data Format for Signals list. 3 Specify the following options: • Object — Enter the name of the MATLAB variable that represents the data object in the MATLAB workspace. Press Enter.
Representing Data in the GUI 4 (Optional) In the Data Information area, click More to expand the dialog box and enter the following optional settings: Input Properties • InterSample — This setting specifies the behavior of the input signals between samples when you transform the resulting models between discrete-time and continuous-time representations. – zoh (zero-order hold) maintains a piecewise-constant input signal between samples.
1 Data Processing • Output — Enter a string to specify the name of one or more output channels. Physical Units of Variables • Input — Enter a string to specify the input units. Tip When you have multiple inputs and outputs, enter a comma-separated list of Input and Output units corresponding to each channel. • Output — Enter a string to specify the output units. Notes — Enter comments about the experiment or the data.
Representing Data in the GUI frequency-domain signals (see the fft reference page), the Fourier transforms are computed as discrete Fourier transforms (DFTs) for this sampling interval. In addition, the sampling instants are used to set the horizontal axis on time plots. Sampling Interval in the Import Data dialog box Specifying Estimation and Validation Data To avoid overfitting, you should use independent data sets to estimate and validate your model.
1 Data Processing Similarly, to specify Validation Data, drag and drop the corresponding data icon into the Validation Data rectangle. Preprocessing Data Using Quick Start As a preprocessing shortcut, select Preprocess > Quick start to simultaneously perform the following four actions: • Subtract the mean value from each channel. Note For information about when to subtract mean values from the data, see “Subtracting Trends from Signals (Detrending)” on page 1-94. • Split data into two parts.
Representing Data in the GUI Creating Data Sets from a Subset of Signal Channels You can create a new data set in the System Identification Tool GUI by extracting subsets of input and output channels from an existing data set. To create a new data set from selected channels: 1 In the System Identification Tool GUI, drag the icon of the data from which you want to select channels to the Working Data rectangle. 2 Select Preprocess > Select channels to open the Select Channels dialog box.
1 Data Processing 3 In the Inputs list, select one or more channels in any of following ways: • Select one channel by clicking its name. • Select adjacent channels by pressing the Shift key while clicking the first and last channel names. • Select nonadjacent channels by pressing the Ctrl key while clicking each channel name. Tip To exclude input channels and create time-series data, clear all selections by holding down the Ctrl key and clicking each selection. To reset selections, click Revert.
Representing Data in the GUI Creating Multiexperiment Data Sets in the GUI • “Why Create Multiexperiment Data?” on page 1-33 • “Limitations on Data Sets” on page 1-33 • “Merging Data Sets” on page 1-33 • “Extracting Specific Experiments from a Multiexperiment Data Set into a New Data Set” on page 1-37 Why Create Multiexperiment Data? You can create a time-domain or frequency-domain data set in the System Identification Tool GUI that includes several experiments.
1 Data Processing Note Before merging several segments of the same data set, verify that the time vector of each data starts at the time when that data segment was actually measured (relative to the other data sets). For example, suppose that you want to combine the data sets tdata, tdata2, tdata3, tdata4 shown in the following figure.
Representing Data in the GUI To merge data sets in the GUI: 1 In the Operations area, select <–Preprocess > Merge experiments from the drop-down menu to open the Merge Experiments dialog box.
1 Data Processing 2 In the System Identification Tool window, drag a data set icon to the Merge Experiments dialog box (to the drop them here to be merged rectangle). The name of the data set is added to the List of sets. tdata and tdata2 to Be Merged Tip To empty the list, click Revert. 3 Repeat step 2 for each data set you want to merge. Go to the next step after adding data sets. 4 In the Data name field, type the name of the new data set. This name must be unique in the Data Board.
Representing Data in the GUI 5 Click Insert to add the new data set to the Data Board in the System Identification Tool window. Data Board Now Contains tdatam with Merged Experiments 6 Click Close to close the Merge Experiments dialog box. Tip To get information about a data set in the System Identification Tool GUI, right-click the data icon to open the Data/model Info dialog box.
1 Data Processing 1 In the System Identification Tool window, drag and drop the tdatam data icon to the Working Data rectangle. tdatam Is Set to Working Data 2 In the Operations area, select Preprocess > Select experiments from the drop-down menu to open the Select Experiment dialog box.
Representing Data in the GUI 3 In the Experiments list, select one or more data sets in either of the following ways: • Select one data set by clicking its name. • Select adjacent data sets by pressing the Shift key while clicking the first and last names. • Select nonadjacent data sets by pressing the Ctrl key while clicking each name. 4 In the Data name field, type the name of the new data set. This name must be unique in the Data Board.
1 Data Processing Viewing Data Properties You can get information about each data set in the System Identification Tool GUI by right-clicking the corresponding data icon. The Data/model Info dialog box opens. This dialog box describes the contents and the properties of the corresponding data set. It also displays any associated notes and the command-line equivalent of the operations you used to create this data.
Representing Data in the GUI To displays the data properties in the MATLAB Command Window, click Present. Renaming Data and Changing Display Color You can rename data and change its display color by double-clicking the data icon in the System Identification Tool GUI. The Data/model Info dialog box opens. This dialog box describes both the contents and the properties of the data. The object description area displays the syntax of the operations you used to create the data in the GUI.
1 Data Processing Data object description History of syntax that created this object Information About the Data You can enter comments about the origin and state of the data in the Diary And Notes area. For example, you might want to include the experiment name, date, and the description of experimental conditions. When you estimate models from this data, these notes are associated with the models. Clicking Present display the portions of this information in the MATLAB Command Window.
Representing Data in the GUI Distinguishing Data Types in the GUI The background color of a data icon is color-coded, as follows: • White background represents time-domain data. • Blue background represents frequency-domain data. • Yellow background represents frequency-response data.
1 Data Processing Tip When you import or create data sets and there is insufficient space for the icons, an additional session window opens automatically. You can drag and drop data between the main System Identification Tool GUI and any extra session windows. Type comments in the Notes field to describe the data sets. When you save a session, as described in “Saving, Merging, and Closing Sessions” on page 12-6, all additional windows and notes are also saved.
Representing Data in the GUI To restore a data set from Trash, drag its icon from Trash to the Data or Model Board in the System Identification Tool window. You can view the Trash contents by double-clicking the Trash icon. Note You must restore data to the Data Board; you cannot drag data icons to the Model Board. To permanently delete all items in Trash, select Options > Empty trash. Exiting a session empties the Trash automatically.
1 Data Processing When you export data to the MATLAB workspace, the resulting variables have the same name as in the System Identification Tool GUI. For example, the following figure shows how to export the time-domain data object data. Exporting Data to the MATLAB® Workspace In this example, the MATLAB workspace contains a variable named data after export.
Representing Time- and Frequency-Domain Data Using iddata Objects Representing Time- and Frequency-Domain Data Using iddata Objects In this section...
1 Data Processing Constructing an iddata Object for Time-Domain Data Use the following syntax to create a time-domain iddata object data: data = iddata(y,u,Ts) You can also specify additional properties, as follows: data = iddata(y,u,Ts,'Property1',Value1,...,'PropertyN',ValueN) For more information about accessing object properties, see “iddata Properties” on page 1-50. In this example, Ts is the sampling time, or the time interval, between successive data samples.
Representing Time- and Frequency-Domain Data Using iddata Objects The following example shows how to create an iddata object using single-input/single-output (SISO) data from dryer2.mat. The input and output each contain 1000 samples with the sampling interval of 0.08 second. load dryer2 data = iddata(y2,u2,0.08) % Load input u2 and output y2. % Create iddata object. MATLAB returns the following output: Time domain data set with 1000 samples. Sampling interval: 0.
1 Data Processing Note You must specify the frequency vector for frequency-domain data. For more information about iddata time and frequency properties, see “Modifying Time and Frequency Vectors” on page 1-59. To specify a continuous-time system, set Ts to 0. You can specify additional properties when you create the iddata object, as follows: data = iddata(y,u,Ts,'Property1',Value1,...,'PropertyN',ValueN) For more information about accessing object properties, see “iddata Properties” on page 1-50.
Representing Time- and Frequency-Domain Data Using iddata Objects MATLAB returns the following object properties and values: Domain: Name: OutputData: y: OutputName: OutputUnit: InputData: u: InputName: InputUnit: Period: InterSample: Ts: Tstart: SamplingInstants: TimeUnit: ExperimentName: Notes: UserData: 'Time' [] [1000x1 double] 'Same as OutputData' {'y1'} {''} [1000x1 double] 'Same as InputData' {'u1'} {''} Inf 'zoh' 0.
1 Data Processing Tip You can use data.y as an alternative to data.OutputData to access the output values, or use data.u as an alternative to data.InputData to access the input values. An iddata object containing frequency-domain data includes frequency-specific properties, such as Frequency for the frequency vector and Units for frequency units (instead of Tstart and SamplingIntervals).
Representing Time- and Frequency-Domain Data Using iddata Objects MATLAB returns the following object properties and values: Domain: Name: OutputData: y: OutputName: OutputUnit: InputData: u: InputName: InputUnit: Period: InterSample: Ts: Units: Frequency: TimeUnit: ExperimentName: Notes: UserData: 'Frequency' [] [501x1 double] 'Same as OutputData' {'y1'} {''} [501x1 double] 'Same as InputData' {'u1'} {''} Inf 'zoh' 0.
1 Data Processing multiexperiment iddata object by splitting the data from a single session into multiple segments to exclude bad data, and merge the good data portions. Note The idfrd object does not support the iddata equivalent of multiexperiment data. Limitations on Data Sets You can only merge data sets that have all of the following characteristics: • Same number of input and output channels. • Same input and output channel names.
Representing Time- and Frequency-Domain Data Using iddata Objects This syntax explicitly assigns the experiment name 'Run4' to the new experiment. The ExperimentName property of the iddata object stores experiment names. For more information about subreferencing experiments in a multiexperiment data set, see “Subreferencing Experiments” on page 1-58.
1 Data Processing Note You do not need to type the entire property name. In this example, sa in data.sa uniquely identifies the SamplingInstants property. You can retrieve the input signal from an iddata object using the following commands: u = get(data,'InputData') or data.InputData or data.u % u is the abbreviation for InputData Similarly, you can retrieve the output data using data.OutputData or data.
Representing Time- and Frequency-Domain Data Using iddata Objects For example, suppose the iddata object data contains three output channels (named y1, y2, and y3), and four input channels (named u1, u2, u3, and u4).
1 Data Processing Subreferencing Experiments Use the following general syntax to subreference specific experiments in iddata objects: data(samples,outputchannels,inputchannels,experimentname) In this syntax, samples specify one or more sample indexes, outputchannels and inputchannels specify channel indexes or channel names, and experimentname specifies experiment indexes or names. When specifying several experiment names, you must use a cell array of name strings.
Representing Time- and Frequency-Domain Data Using iddata Objects Modifying Time and Frequency Vectors The iddata object stores time-domain data or frequency-domain data and has several properties that specify the time or frequency values. To modify the time or frequency values, you must change the corresponding property values. Note You can modify the property SamplingInstants by setting it to a new vector with the length equal to the number of data samples.
1 Data Processing iddata Time-Vector Properties (Continued) Property Description Syntax Example Tstart Starting time of the experiment. To change starting time of the first data sample to 24: • For a single experiment, Ts is a scalar value. • For multiexperiement data with Ne experiments, Ts is a 1-by-Ne cell array, and each cell contains the sampling interval of the corresponding experiment. 1-60 data.Tstart = 24 Time units are set by the property TimeUnit.
Representing Time- and Frequency-Domain Data Using iddata Objects iddata Time-Vector Properties (Continued) Property Description Syntax Example SamplingInstants Time values in the time vector, computed from the properties Tstart and Ts. To retrieve the time vector for iddata object data, use: • For a single experiment, get(data,'sa') SamplingInstants is an N-by-1 vector.
1 Data Processing iddata Frequency-Vector Properties Property Description Syntax Example Frequency Frequency values at which the Fourier transforms of the signals are defined. To specify 100 frequency values in log space, ranging between 0.1 and 100, use the following syntax: • For a single experiment, Frequency is a scalar value. data.
Representing Time- and Frequency-Domain Data Using iddata Objects Naming, Adding, and Removing Data Channels • “What Are Input and Output Channels?” on page 1-63 • “Naming Channels” on page 1-63 • “Adding Channels” on page 1-64 • “Modifying Channel Data” on page 1-64 What Are Input and Output Channels? A multivariate system might contain several input variables or several output variables, or both. When an input or output signal includes several measured variables, these variables are called channels.
1 Data Processing If you do not specify channel names when you create the iddata object, the toolbox assigns default names. By default, the output channels are named 'y1','y2',...,'yn', and the input channels are named 'u1','u2',...,'un'. Adding Channels You can add data channels to an iddata object. For example, consider an iddata object named data that contains an input signal with four channels. To add a fifth input channel, stored as the vector Input5, use the following syntax: data.
Representing Time- and Frequency-Domain Data Using iddata Objects Concatenating iddata Objects • “iddata Properties Storing Input and Output Data” on page 1-65 • “Horizontal Concatenation” on page 1-65 • “Vertical Concatenation” on page 1-66 iddata Properties Storing Input and Output Data The InputData iddata property stores column-wise input data, and the OutputData property stores column-wise output data. For more information about accessing iddata properties, see “iddata Properties” on page 1-50.
1 Data Processing contains channel names that are already present in dataJ with J < K, the dataK channels are ignored. • Combining duplicate output channels. If data1,data2,...,dataN have input channels with duplicate user-defined names, only the output channels with unique names are added during the concatenation. Vertical Concatenation Vertical concatenation of iddata objects creates a new iddata object that vertically stacks the input and output data values in the corresponding data channels.
Representing Frequency-Response Data Using idfrd Objects Representing Frequency-Response Data Using idfrd Objects In this section... “idfrd Constructor” on page 1-67 “idfrd Properties” on page 1-68 “Subreferencing idfrd Objects” on page 1-70 “Concatenating idfrd Objects” on page 1-71 “See Also” on page 1-74 idfrd Constructor The idfrd represents complex frequency-response data.
1 Data Processing Note When you work at the command line, you can only create idfrd objects from complex values of G(eiw). For a SISO system, response can be a vector. You can specify object properties when you create the idfrd object using the constructor syntax: fr_data = idfrd(response,f,Ts, 'Property1',Value1,...,'PropertyN',ValueN) idfrd Properties To view the properties of the idfrd object, you can use the get command.
Representing Frequency-Response Data Using idfrd Objects response and f are variables in the MATLAB Workspace browser, representing the frequency-response data and frequency values, respectively. MATLAB returns the following object properties and values: ans = Name: Frequency: ResponseData: SpectrumData: CovarianceData: NoiseCovariance: Units: Ts: InputDelay: EstimationInfo: InputName: OutputName: InputUnit: OutputUnit: Notes: UserData: '' [100x1 double] [1x1x100 double] [] [] [] 'rad/s' 0.
1 Data Processing If you import fr_data into the System Identification Tool GUI, this data has the name DC_Converter in the GUI, and not the variable name fr_data. MATLAB returns the following object properties and values: ans = Name: Frequency: ResponseData: SpectrumData: CovarianceData: NoiseCovariance: Units: Ts: InputDelay: EstimationInfo: InputName: OutputName: InputUnit: OutputUnit: Notes: UserData: 'DC_Converter' [100x1 double] [1x1x100 double] [] [] [] 'rad/s' 0.
Representing Frequency-Response Data Using idfrd Objects For example, the following command references frequency-response data from input channel 3 to output channel 2: fr_data(2,3) You can also access the data in specific channels using channel names. To list multiple channel names, use a cell array.
1 Data Processing the number of output channels, nu is the number of input channels, and nf is a vector of frequency values (see “idfrd Properties” on page 1-68). Horizontal Concatenation of idfrd Objects The following syntax creates a new idfrd object data that contains the horizontal concatenation of data1,data2,...,dataN: data = [data1,data2,...,dataN] data contains the frequency responses from all of the inputs in data1,data2,...,dataN to the same outputs.
Representing Frequency-Response Data Using idfrd Objects The resulting idfrd object data contains the frequency responses from the same inputs in data1,data2,...,dataN to all the outputs. The following diagram is a graphical representation of vertical concatenation of frequency-response data. The (j,i,:) vector of the resulting response data represents the frequency response from the ith input to the jth output at all frequencies.
1 Data Processing When the SpectralData property of individual idfrd objects is not empty, horizontal and vertical concatenation handle SpectralData, as follows. In case of horizontal concatenation, there is no meaningful way to combine the SpectralData of individual idfrd objects and the resulting SpectralData property is empty. An empty property results because each idfrd object has its own set of noise channels, where the number of noise channels equals the number of outputs.
Analyzing Data Quality Using Plots Analyzing Data Quality Using Plots In this section... “Supported Data Plots” on page 1-75 “Plotting Data in the System Identification Tool GUI” on page 1-75 “Plotting Data at the Command Line” on page 1-81 Supported Data Plots You can create the following plots of your data: • Time plot — Shows data values as a function of time.
1 Data Processing • “Working with a Frequency Function Plot” on page 1-80 How to Plot Data in the GUI After importing data into the System Identification Tool GUI, as described in “Representing Data in the GUI” on page 1-13, you can plot the data. To create one or more plots, select the corresponding check box in the Data Views area of the System Identification Tool GUI. An active data icon has a thick line in the icon, while an inactive data set has a thin line.
Analyzing Data Quality Using Plots To close a plot, clear the corresponding check box in the System Identification Tool GUI. Tip To get information about working with a specific plot, select a help topic from the Help menu in the plot window. Working with a Time Plot The Time plot only shows time-domain data. In this example, data1 is displayed on the time plot because, of the three data sets, it is the only one that contains time-domain input and output.
1 Data Processing Note You can plot several data sets with the same input and output channel names. The plot displays data for all channels that have the same name. To view a different input-output channel pair, select it from the Channel menu. For more information about selecting different input and output pairs, see “Selecting Measured and Noise Channels in Plots” on page 12-18. The following table summarizes options that are specific to time plots, which you can select from the plot window menus.
Analyzing Data Quality Using Plots The top axes show the input and the bottom axes show the output. The vertical axis of each plot is labeled with the corresponding channel name. Periodograms of data1 and data3fd Data Spectra Plot Options Action Command Toggle display between periodogram and spectral estimate. Select Options > Periodogram or Options > Spectral analysis. Change frequency units. Select Style > Frequency (rad/s) or Style > Frequency (Hz).
1 Data Processing Working with a Frequency Function Plot For time-domain data, the Frequency function plot shows the empirical transfer function estimate (etfe). For frequency-domain data, the plot shows the ratio of output to input data. The frequency-response plot shows the amplitude and phase plots of the corresponding frequency response. For more information about frequency-response data, see “Importing Frequency-Response Data into MATLAB” on page 1-10.
Analyzing Data Quality Using Plots Frequency Function Plot Options (Continued) Action Command Toggle frequency scale between linear and logarithmic. Select Style > Linear frequency scale or Style > Log frequency scale. Toggle amplitude scale between linear and logarithmic. Select Style > Linear amplitude scale or Style > Log amplitude scale. Plotting Data at the Command Line The following table summarizes the commands available for plotting time-domain, frequency-domain, and frequency-response data.
1 Data Processing Commands for Plotting Data (Continued) Command Description Example ffplot For frequency-response data only. Shows the magnitude and phase of the frequency response on a linear frequency scale (hertz). To plot idfrd data: The type of plot corresponds to the type of data. For example, plotting time-domain data generates a time plot, and plotting frequency-response data generates a frequency-response plot.
Analyzing Data Quality Using Plots When data.intersample = 'zoh', the input is piece-wise constant between sampling points on the plot. For more information about properties, see the iddata reference page. You can generate plots of the input data in the time domain using: plot(data.sa,data.u) To plot frequency-domain data, you can use the following syntax: semilogx(data.fr,abs(data.u)) In this case, sa is an abbreviation of the iddata property SamplingInstants.
1 Data Processing Getting Advice About Your Data You can use the advice command to get information about your time-domain or frequency-domain data. This command does not support frequency-response data. Note If you are using the System Identification Tool GUI, you must export your data to the MATLAB workspace before you can use the advice command on this data. For more information about exporting data, see “Exporting Models from the GUI to the MATLAB Workspace” on page 12-13.
Getting Advice About Your Data The following example shows how to get information about your data. Consider data from a single-input/single-output system sampled at 0.08 s. Use these commands to load the data and estimate the delay in the system: load dryer2 data=iddata(y2,u2,0.
1 Data Processing Selecting Subsets of Data In this section... “Why Select Subsets of Data?” on page 1-86 “Selecting Data Using the GUI” on page 1-87 “Selecting Data at the Command Line” on page 1-89 Why Select Subsets of Data? You can use data selection to create independent data sets for estimation and validation. You can also use data selection as a way to clean the data and exclude parts with noisy or missing information.
Selecting Subsets of Data Selecting Data Using the GUI • “Ways to Select Data in the GUI” on page 1-87 • “Selecting a Range for Time-Domain Data” on page 1-87 • “Selecting a Range of Frequency-Domain Data” on page 1-89 Ways to Select Data in the GUI You can use System Identification Tool GUI to select ranges of data on a time-domain or frequency-domain plot. Selecting data in the frequency domain is equivalent to passband-filtering the data.
1 Data Processing To extract a subset of time-domain data and save it as a new data set: 1 Import time-domain data into the System Identification Tool GUI, as described in “Representing Data in the GUI” on page 1-13. 2 Drag the data set you want to subset to the Working Data area. 3 If your data contains multiple I/O channels, in the Channel menu, select the channel pair you want to view. The upper plot corresponds to the input signal, and the lower plot corresponds to the output signal.
Selecting Subsets of Data 7 To select another range, repeat steps 4 to 6. Selecting a Range of Frequency-Domain Data Selecting a range of values in frequency domain is equivalent to filtering the data. For more information about data filtering, see “Filtering Frequency-Domain or Frequency-Response Data in the GUI” on page 1-110. Selecting Data at the Command Line Selecting ranges of data values is equivalent to subreferencing the data.
1 Data Processing Handling Missing Data and Outliers In this section... “Handling Missing Data” on page 1-90 “Handling Outliers” on page 1-91 “Example – Extracting and Modeling Specific Data Segments” on page 1-92 “See Also” on page 1-93 Handling Missing Data Data acquisition failures sometimes result in missing measurements both in the input and the output signals.
Handling Missing Data and Outliers Apply the misdata command to the new data object. For example: dat1 = misdata(dat); plot(dat,dat1) % Check how the missing data % was estimated on a time plot Handling Outliers Malfunctions can produce errors in measured values, called outliers. Such outliers might be caused by signal spikes or by measurement malfunctions. If you do not remove outliers from your data, this can adversely affect the estimated models.
1 Data Processing Tip The inputs in each of the data segments must be consistently exciting the system. Splitting data into meaningful segments for steady-state data results in minimum information loss. Avoid making data segments too small. • Manually replace outliers with NaNs and then use the misdata command to reconstruct flagged data. This approach treats outliers as missing data and is described in “Handling Missing Data” on page 1-90.
Handling Missing Data and Outliers % Plot the data in a MATLAB Figure window plot(data) % Create multiexperiment data set % by merging data segments datam = merge(data(1:340),... data(500:897),... data(1001:1200),...
1 Data Processing Subtracting Trends from Signals (Detrending) In this section...
Subtracting Trends from Signals (Detrending) For linear system identification, detrending steady-state data is useful because arbitrary differences between the input and output signal levels cannot be explained by a linear model. For nonlinear black-box system identification, detrending data might be helpful when signals vary around a large signal level, you might improve computational accuracy by first removing the means.
1 Data Processing When you are working with transient data (such as step or impulse response), do not remove the mean from the data. With transient data, when the output at zero input is not zero, you might want to subtract the constant value corresponding to the time before the input is applied. For nonlinear black-box models, detrending data is not always necessary because these models can include the trend as part of the model.
Subtracting Trends from Signals (Detrending) Tip (For linear modeling only) Select Preprocess > Quick start to perform several data cleaning operations, including removing the mean value from each signal, splitting data into two halves, specifying the first half as model estimation data (or Working Data), and specifying the second half as model Validation Data. To detrend data using the GUI: 1 In the System Identification Tool, drag the data set you want to detrend to the Working Data rectangle.
1 Data Processing Before you can perform this task, you must represent your data as an iddata object in the MATLAB workspace, as described in “Representing Time- and Frequency-Domain Data Using iddata Objects” on page 1-47. To remove mean values from each channel in data (which is an iddata object), use the following syntax: data = detrend(data); To subtract one linear trend, use the following syntax: data = detrend(data,1); In this case, 1 indicates that a first-order trend is removed from each signal.
Subtracting Trends from Signals (Detrending) For example, Ynew = Ysim+y0.
1 Data Processing Resampling Data In this section... “What Is Resampling?” on page 1-100 “Resampling Data Using the GUI” on page 1-101 “Resampling Data at the Command Line” on page 1-101 “Resampling Data Without Aliasing Effects” on page 1-103 “See Also” on page 1-106 What Is Resampling? Resampling data signals in the System Identification Toolbox product applies an antialiasing (lowpass) FIR filter to the data and changes the sampling rate of the signal by decimation or interpolation.
Resampling Data Resampling Data Using the GUI Use the System Identification Tool GUI to resample time-domain data. To specify additional options, such as the prefilter order, see “Resampling Data at the Command Line” on page 1-101. The System Identification Tool GUI uses idresamp to interpolate or decimate the data. For more information about this command, type help idresamp at the prompt.
1 Data Processing Note resample uses the Signal Processing Toolbox™ command, when this toolbox is installed on your computer. If this toolbox is not installed, use idresamp instead. idresamp only lets you specify the filter order, whereas resample also lets you specify filter coefficients and the design parameters of the Kaiser window.
Resampling Data The data.InterSample property of the iddata object is taken into account during resampling (for example, first-order hold or zero-order hold). For more information, see “iddata Properties” on page 1-50. Resampling Data Without Aliasing Effects Typically, you decimate a signal to remove the high-frequency contributions that result from noise from the total energy. Ideally, you want to remove the energy contribution due to noise and preserve the energy density of the signal.
1 Data Processing The following example illustrates how resample avoids folding effects: % Construct fourth-order MA-process m0 = idpoly(1,[ ],[1 1 1 1]); % Generate error signal e = idinput(2000,'rgs'); e = iddata([],e,'Ts',1); % Simulate the output using error signal y = sim(m0,e); % Estimate signal spectrum g1 = spa(y); % Estimate spectrum of modified signal including % every fourth sample of the original signal. % This command automatically sets Ts to 4.
Resampling Data Folding Effects with Manual Decimation 1-105
1 Data Processing Use resample to decimate the signal before estimating the spectrum and plot the frequency response, as follows: g3 = spa(resample(y,1,4)); figure ffplot(g1,g3) The following figure shows that the estimated spectrum of the resampled signal has the same amplitude as the original spectrum. Thus, there is no indication of folding effects when you use resample to eliminate aliasing.
Filtering Data Filtering Data In this section... “Supported Filters” on page 1-107 “Choosing to Prefilter Your Data” on page 1-107 “How to Filter Data Using the GUI” on page 1-108 “How to Filter Data at the Command Line” on page 1-111 “See Also” on page 1-114 Supported Filters You can filter the input and output signals through a linear filter before estimating a model in the System Identification Tool GUI or at the command line.
1 Data Processing To get a reliable noise model, avoid prefiltering the data. Instead, set the Focus property of the estimation algorithm to Simulation. For more information about the Focus property, see the Algorithm Properties reference page. Note When you prefilter during model estimation, the filtered data is used to only model the input-to-output dynamics. However, the disturbance model is calculated from the unfiltered data.
Filtering Data 4 If your data contains multiple input/output channels, in the Channel menu, select the channel pair you want to view. Although you view only one channel pair at a time, the filter applies to all input/output channels in this data set. 5 Select the data of interest using one of the following ways: • Graphically — Draw a rectangle with the mouse on either the input-signal or the output-signal plot to select the desired frequency interval.
1 Data Processing Filtering Frequency-Domain or Frequency-Response Data in the GUI For frequency-domain and frequency-response data, filtering is equivalent to selecting specific data ranges. To select a range of data in frequency-domain or frequency-response data: 1 Import data into the System Identification Tool GUI, as described in “Representing Data in the GUI” on page 1-13. 2 Drag the data set you want you want to filter to the Working Data area. 3 Select <–Preprocess > Select range.
Filtering Data Tip If you need to change the frequency units from rad/s to Hz, select Style > Frequency (Hz). To change the frequency units from Hz to rad/s, select Style > Frequency (rad/s). 6 In the Range is list, select one of the following: • Pass band — Allows data in the selected frequency range. • Stop band — Excludes data in the selected frequency range. 7 In the Data name field, enter the name of the data set containing the selected data. 8 Click Insert.
1 Data Processing In this case, w1 and wh represent the low and high frequencies of the passband, respectively. You can specify several passbands, as follows: filter=[[w1l,w1h];[ w2l,w2h]; ....;[wnl,wnh]] The filter is an n-by-2 matrix, where each row defines a passband in radians per second. To define a stopband between ws1 and ws2, use filter = [0 ws1; ws2 Nyqf] where, Nyqf is the Nyquist frequency. For time-domain data, the passband filtering is cascaded Butterworth filters of specified order.
Filtering Data filter = idm filter = {num,den} filter = {A,B,C,D} idm is a SISO idmodel or LTI object. For more information about LTI objects, see the Control System Toolbox documentation. {num,den} defines the filter as a transfer function as a cell array of numerator and denominator filter coefficients. {A,B,C,D} is a cell array of SISO state-space matrices.
1 Data Processing When you apply idfilt to an idfrd data object, the data is first converted to a frequency-domain iddata object (see “Transforming Between Frequency-Domain and Frequency-Response Data” on page 1-128). The result is an iddata object. See Also To learn how to filter data during linear model estimation instead, you can set the Focus property of the estimation algorithm to Filter and specify the filter characteristics.
Generating Data Using Simulation Generating Data Using Simulation In this section... “Commands for Generating and Simulating Data” on page 1-115 “Example – Creating Data with Periodic Inputs” on page 1-116 “Example – Generating Data Using Simulation” on page 1-117 “Simulating Data Using Other MathWorks Products” on page 1-118 Commands for Generating and Simulating Data You can generate input data and simulate output data using a specified model structure.
1 Data Processing Commands for Generating and Simulating Data (Continued) Command Description idinput Constructs a signal with the desired characteristics, such as a random Gaussian or binary signal or a sinusoid, and returns a matrix of input values. sim Simulates response data based on existing linear or nonlinear parametric model in the MATLAB workspace. Example u = iddata([],... idinput(400,'rbs',[0 0.
Generating Data Using Simulation % Construct input data and noise u = iddata([],u,'Period',10); e = iddata([],randn(1500,1)); % Simulate model output with noise y = sim(m0,[u e]) % Estimate frequency response g = etfe([y u]) % Generate Bode plot bode(g,'x',m0) For periodic input, etfe honors the period and computes the frequency response using an appropriate frequency grid. In this case, the Bode plot shows a good fit at the five excited frequencies.
1 Data Processing 4 Simulate the model output. sim(m,u) 5 Compare model output to measured data to see how well the models captures the underlying dynamics. compare(z8,m) Simulating Data Using Other MathWorks Products You can also simulate data using the Simulink® and Signal Processing Toolbox software. Data simulated outside the System Identification Toolbox product must be in the MATLAB workspace.
Transforming Between Time- and Frequency-Domain Data Transforming Between Time- and Frequency-Domain Data In this section...
1 Data Processing 1 In the System Identification Tool GUI, drag the icon of the data you want to transform to the Working Data rectangle, as shown in the following figure.
Transforming Between Time- and Frequency-Domain Data 2 In the Operations area, select <–Preprocess > Transform data in the drop-down menu to open the Transform Data dialog box.
1 Data Processing 3 In the Transform to drop-down list, select one of the following: • Frequency Function — Create a new idfrd object using the spafdr method. Go to step 4. • Frequency Domain Data — Create a new iddata object using the fft method. Go to step 6. 4 In the Frequency Spacing list, select the spacing of the frequencies at which the frequency function is estimated: • linear — Uniform spacing of frequency values between the endpoints.
Transforming Between Time- and Frequency-Domain Data Transforming Frequency-Domain Data In the System Identification Tool GUI, frequency-domain data has an icon with a green background. You can transform frequency-domain data to time-domain or frequency-response (frequency-function) data. Transforming from time-domain or frequency-domain data to frequency-response data is equivalent to estimating a nonparametric model of the data using the spafdr method.
1 Data Processing Transforming Frequency-Response Data In the System Identification Tool GUI, frequency-response data has an icon with a yellow background. You can transform frequency-response data to frequency-domain data (iddata object) or to frequency-response data with a different frequency resolution. When you select to transform single-input/single-output (SISO) frequency-response data to frequency-domain data, the toolbox creates outputs that equal the frequency responses, and inputs equal to 1.
Transforming Between Time- and Frequency-Domain Data frequencies, and also make the frequency vector coarser in the region outside the system dynamics. Typically, high-frequency noise dominates away from frequencies where interesting system dynamics occur. The System Identification Tool GUI lets you specify logarithmic frequency spacing, which results in a variable frequency resolution. Note The spafdr command lets you lets you specify any variable frequency resolution.
1 Data Processing See Also For a description of time-domain, frequency-domain, and frequency-response data, see “Importing Data into the MATLAB Workspace” on page 1-5. To learn how to transform data at the command line instead of the GUI, see “Transforming Data Domain at the Command Line” on page 1-126.
Transforming Between Time- and Frequency-Domain Data Original Data Format To Time Domain (iddata object) To Frequency Domain (iddata object) To Frequency Function (idfrd object) Frequency Domain (iddata object) Yes, using ifft. No. Yes, using etfe, spa, or spafdr. Frequency Function (idfrd object) No. Yes. Calculation creates frequency-domain iddata object that has the same ratio between output and input as the original idfrd object. Yes.
1 Data Processing Command Description Syntax Example fft Transforms time-domain data to the frequency domain. To transform time-domain iddata object t_data to frequency-domain iddata object f_data with N frequency points, use: You can specify N, the number of frequency values. ifft Transforms frequency-domain data to the time domain. Frequencies are linear and equally spaced.
Transforming Between Time- and Frequency-Domain Data high-frequency noise dominates away from frequencies where interesting system dynamics occur. Note You cannot transform an idfrd object to a time-domain iddata object. To transform an idfrd object with the name idfrdobj to a frequency-domain iddata object, use the following syntax: dataf = iddata(idfrdobj) The resulting frequency-domain iddata object contains values at the same frequencies as the original idfrd object.
1 Data Processing If you are working with multiple inputs, you also have the option of storing the contribution by each input as an independent experiment in a multiexperiment data set. To transform an idfrd object with the name idfrdobj to a multiexperiment data set datf, where each experiment corresponds to each of the inputs in idfrdobj datf = iddata(idfrdobj,'me') In this example, the additional argument 'me' specifies that multiple experiments are created.
Manipulating Complex-Valued Data Manipulating Complex-Valued Data In this section... “Supported Operations for Complex Data” on page 1-131 “Processing Complex iddata Signals at the Command Line” on page 1-131 Supported Operations for Complex Data System Identification Toolbox estimation algorithms support complex data. For example, the following estimation commands estimate complex models from complex data: ar, armax, arx, bj, covf, ivar, iv4, oe, pem, spa, and n4sid.
1 Data Processing Command Description complex(data) For time-domain data, this command makes the iddata object complex—even when the imaginary parts are zero. For frequency-domain data that only stores the values for nonnegative frequencies, such that realdata(data)=1, it adds signal values for negative frequencies using complex conjugation. imag(data) Selects the imaginary parts of each signal in iddata object.
2 Choosing Your System Identification Strategy • “Recommended Model Estimation Sequence” on page 2-2 • “Supported Models for Time- and Frequency-Domain Data” on page 2-4 • “Supported Continuous-Time and Discrete-Time Models” on page 2-7 • “Commands for Model Estimation” on page 2-9 • “Creating Model Structures at the Command Line” on page 2-11 • “Modeling Multiple-Output Systems” on page 2-21
2 Choosing Your System Identification Strategy Recommended Model Estimation Sequence System identification is an iterative process, where you identify models with different structures from data and compare model performance. You start by estimating the parameters of simple model structures. If the model performance is poor, you gradually increase the complexity of the model structure. Ultimately, you choose the simplest model that best describes the dynamics of your system.
Recommended Model Estimation Sequence In the System Identification Tool GUI. Select to estimate the BJ and ARMAX linear parametric models. At the command line. Use the bj or armax commands. For more information, see “Identifying Input-Output Polynomial Models” on page 3-41. 3 Nonlinear ARX or Hammerstein-Wiener models provide nonlinear structures. For more information, see Chapter 4, “Nonlinear Black-Box Model Identification”.
2 Choosing Your System Identification Strategy Supported Models for Time- and Frequency-Domain Data In this section... “Supported Models for Time-Domain Data” on page 2-4 “Supported Models for Frequency-Domain Data” on page 2-5 Supported Models for Time-Domain Data Continuous-Time Models You can directly estimate the following types of continuous-time models: • Low-order transfer functions. See “Identifying Low-Order Transfer Functions (Process Models)” on page 3-22. • Input-output polynomial models.
Supported Models for Time- and Frequency-Domain Data Nonlinear Models You can estimate discrete-time Hammerstein-Wiener and nonlinear ARX models from time-domain data. See Chapter 4, “Nonlinear Black-Box Model Identification”. You can also estimate nonlinear grey-box models from time-domain data. See “Estimating Nonlinear Grey-Box Models” on page 5-16.
2 Choosing Your System Identification Strategy data, you can estimate continuous-time black-box models with canonical parameterization. See “Identifying State-Space Models” on page 3-73. To get a linear, continuous-time model of arbitrary structure for frequency-domain data, you can estimate a discrete-time model and use d2c to transform it to a continuous-time model. Discrete-Time Models You can estimate only ARX and output-error (OE) polynomial models using frequency-domain data.
Supported Continuous-Time and Discrete-Time Models Supported Continuous-Time and Discrete-Time Models For linear and nonlinear ODEs (grey-box models), you can specify any ordinary differential or difference equation to represent your continuous-time or discrete-time model in state-space form, respectively. In the linear case, both time-domain and frequency-domain data are supported. In the nonlinear case, only time-domain data is supported.
2 Choosing Your System Identification Strategy Supported Discrete-Time Models 2-8 Model Type Description Linear, input-output polynomial models Estimate arbitrary-order, linear parametric models from time- or frequency-domain data. To get a discrete-time model, your data sampling interval must be set to the (nonzero) value you used to sample in your experiment. Nonlinear black-box models Estimate from time-domain data only.
Commands for Model Estimation Commands for Model Estimation The quickest way to both construct a model object and estimate the model parameters is to use estimation commands. Note For ODEs (grey-box models), you must first construct the model structure and then apply an estimation command to the resulting model object. For ARMAX, Box-Jenkins, and Output-Error Models—which you can only estimate using the iterative prediction-error method—use the armax, bj, and oe estimation commands, respectively.
2 Choosing Your System Identification Strategy Commands for Constructing and Estimating Models (Continued) 2-10 Model Type Estimation Commands Linear time-series models ar arx (for multiple outputs) ivar Nonlinear ARX models nlarx Hammerstein-Wiener models nlhw
Creating Model Structures at the Command Line Creating Model Structures at the Command Line In this section... “About System Identification Toolbox Model Objects” on page 2-11 “When to Construct a Model Structure Independently of Estimation” on page 2-12 “Commands for Constructing Model Structures” on page 2-13 “Model Properties” on page 2-14 “See Also” on page 2-20 About System Identification Toolbox Model Objects Objects are based on model classes.
2 Choosing Your System Identification Strategy model object. For example, the estimation method n4sid is unique to the state-space model object idss. Every class has a special method for creating objects of that class, called the constructor. Using a constructor creates an instance of the corresponding class or instantiates the object. The constructor name is the same as the class name.
Creating Model Structures at the Command Line Commands for Constructing Model Structures The following table summarizes the model constructors available in the System Identification Toolbox product for representing various types of models. After model estimation, you can recognize the corresponding model objects in the MATLAB Workspace browser by their class names. The name of the constructor matches the name of the object it creates.
2 Choosing Your System Identification Strategy Summary of Model Constructors (Continued) Model Constructor Resulting Model Class Single or Multiple Outputs? idgrey Linear ordinary differential or difference equations (grey-box models). You write an M-file that translates user parameters to state-space matrices. Single- and multiple-output models. idnlgrey Nonlinear ordinary differential or difference equation (grey-box models).
Creating Model Structures at the Command Line Categories of Model Properties The way a model object stores information is defined by the properties of the corresponding model class. Each model object has properties for storing information that are relevant only to that specific model type. However, the idarx, idgrey, idpoly, idproc, and idss model objects are based on the idmodel superclass and inherit all idmodel properties.
2 Choosing Your System Identification Strategy - EstimationInfo Structure includes read-only fields that describe the estimation data set, quantitative model quality measures, search termination conditions, how the initial states are handled, and any warnings encountered during the estimation. For information about getting help on object properties, see “Getting Help on Model Properties at the Command Line” on page 2-19.
Creating Model Structures at the Command Line For linear models, you can use a shortcut to specify the second-level Algorithm properties, such as Advanced. With this syntax, you can reference the structure fields by name without specifying the structure to which these fields belong. However, when estimating nonlinear black-box models, you must set the specific fields of the Advanced Algorithm structure and the nonlinearity estimators before estimation.
2 Choosing Your System Identification Strategy ans = 1.0000 -0.8441 -0.1539 0.2278 0.1239 Similarly, to access the uncertainties in these parameter estimates, type the following command: m_arx.da ans = 0 0.0357 0.0502 0.0438 0.0294 Property names are not case sensitive. You do not need to type the entire property name if the first few letters uniquely identify the property. To change property values for an existing model object, use the set command or dot notation.
Creating Model Structures at the Command Line Getting Help on Model Properties at the Command Line If you need to learn more about model properties while working at the command line, you can use the idprops command to list the properties and values for each object. Some model objects are based on the superclasses idmodel and idnlmodel and inherit the properties of these superclasses. For such model objects, you must independently look up the properties for both the model object and for its superclass.
2 Choosing Your System Identification Strategy Help Commands for Model Properties (Continued) Model Class Help Commands idnlarx idprops idnlarx idprops idnlarx Algorithm idprops idnlarx EstimationInfo Also inherits properties from idnlmodel. idnlhw idprops idnlhw idprops idnlhw Algorithm idprops idnlhw EstimationInfo Also inherits properties from idnlmodel. See Also Validate each model directly after estimation to help fine-tune your modeling strategy.
Modeling Multiple-Output Systems Modeling Multiple-Output Systems In this section...
2 Choosing Your System Identification Strategy Modeling Multiple Outputs Directly You can estimate the following types of models for multiple-output data: • Impulse- and step-response models • Frequency-response models • Linear ARX models • State-space models • Nonlinear ARX and Hammerstein-Wiener models • Linear and nonlinear ODEs Tip Estimating multiple-output state-space models directly generally produces better results than estimating other types of multiple-output models directly.
Modeling Multiple-Output Systems After validating the single-output models, use vertical concatenation to combine these partial models into a single multiple-output model. For more information about concatenation, see “Concatenating iddata Objects” on page 1-65 or “Concatenating idfrd Objects” on page 1-71. You can try refining the concatenated multiple-output model using the original (multiple-output) data set.
2 Choosing Your System Identification Strategy the Algorithm fields for nonlinear estimation, see the idnlarx and idnlhw reference pages. Note For multiple-output idnlarx models containing neuralnet or treepartition nonlinearity estimators, output weighting is ignored because each output is estimated independently.
3 Linear Model Identification • “Identifying Frequency-Response Models” on page 3-2 • “Identifying Impulse-Response Models” on page 3-14 • “Identifying Low-Order Transfer Functions (Process Models)” on page 3-22 • “Identifying Input-Output Polynomial Models” on page 3-41 • “Identifying State-Space Models” on page 3-73 • “Refining Linear Parametric Models” on page 3-103 • “Extracting Parameter Values from Linear Models” on page 3-108 • “Extracting Dynamic Model and Noise Model Separately” on page 3-110 • “Tr
3 Linear Model Identification Identifying Frequency-Response Models In this section...
Identifying Frequency-Response Models Data Supported by Frequency-Response Models You can estimate spectral analysis models from data with the following characteristics: • Complex or real data. • Time- or frequency-domain iddata or idfrd data object. To learn more about estimating time-series models, see Chapter 6, “Time Series Model Identification”. • Single- or multiple-output data.
3 Linear Model Identification Note For etfe, only the Linear option is available. – In the Frequencies field, enter the number of frequency points. For time-domain data, the frequency ranges from 0 to the Nyquist frequency. For frequency-domain data, the frequency ranges from the smallest to the largest frequency in the data set. 4 In the Frequency Resolution field, enter the frequency resolution, as described in “Options for Frequency Resolution” on page 3-6.
Identifying Frequency-Response Models How to Estimate Frequency-Response Models at the Command Line You can use the etfe, spa, and spafdr commands to estimate spectral models. The following table provides a brief description of each command and usage examples. The resulting models are stored as idfrd model objects. For detailed information about the commands and their arguments, see the corresponding reference page.
3 Linear Model Identification You can choose from the following three spectral-analysis methods: • etfe (Empirical Transfer Function Estimate) For input-output data. This method computes the ratio of the Fourier transform of the output to the Fourier transform of the input. For time-series data. This method computes a periodogram as the normalized absolute squares of the Fourier transform of the time series. ETFE works well for highly resonant systems or narrowband systems.
Identifying Frequency-Response Models This section supports the estimation procedures “How to Estimate Frequency-Response Models in the GUI” on page 3-3 and “How to Estimate Frequency-Response Models at the Command Line” on page 3-5. What Is Frequency Resolution? Frequency resolution is the size of the smallest frequency for which details in the frequency response and the spectrum can be resolved by the estimate. A resolution of 0.
3 Linear Model Identification you increase the resolution in a specific frequency range, such as near a resonance frequency. Conversely, you can make the frequency grid coarser in the region where the noise dominates—at higher frequencies, for example. Such customizing of the frequency grid assists in the estimation process by achieving high fidelity in the frequency range of interest. For spafdr, the frequency resolution around the frequency k is the value R(k).
Identifying Frequency-Response Models y(t) = G(q)u(t) + v(t) where u(t) and y(t) are the input and output signals, respectively. G(q) is called the transfer function of the system—it takes the input to the output and captures the system dynamics.
3 Linear Model Identification ˆ ( ω) = Φ ˆ ( ω) − Φ v y ˆ ( ω) 2 Φ yu ˆ ( ω) Φ u This equation for the noise spectrum is derived by assuming the linear relationship y(t) = G(q)u(t) + v(t) , that u(t) is independent of v(t), and the following relationships between the spectra: ( ) Φ y (ω) = G eiω 2 Φu (ω) + Φ v (ω) ( ) Φ yu (ω) = G eiω Φu (ω) where the noise spectrum is given by the following equation: Φ v (ω) ≡ ∞ ∑ Rv (τ) e−iwτ τ=−∞ ˆ (ω) ˆ (ω) is the output-input cross-spectrum and Φ u Φ is
Identifying Frequency-Response Models 2 Compute the Fourier transforms of the covariances and the cross-covariance, as follows: M ˆ (ω) = Φ y ˆ (ω) = Φ u ∑ ˆ (τ)W (τ) e−iωτ R M y ∑ ˆ (τ)W (τ) e−iωτ R u M τ=− M M τ=− M M ˆ (ω) = Φ yu ∑ ˆ (τ)W (τ) e−iωτ R M yu τ=− M where WM (τ) is called the lag window with the width M.
3 Linear Model Identification where WM(k) is the lag window, and M is the width of the lag window. The output covariance Ry(kT) is given by the following discrete representation: ˆ (kT ) = 1 R y N N ∑ y(lT − kT ) y(lT ) l =1 Because there is no scaling in a discrete Fourier transform of a vector, the purpose of T is to relate the discrete transform of a vector to the physically meaningful transform of the measured signal.
Identifying Frequency-Response Models % energy spectrum, where S1 is scaled by T S1 = sum(phiy)/length(phiy)/T % Compute average energy of the signal S2 = sum(y.y.^2)/size(y,1) In this code, phiy contains Φ y (ω) between ω = 0 and ω = π T with the frequency step given as follows: ⎛ ⎞ π ⎜ ⎟ ⎝ T ⋅ length(phiy) ⎠ MATLAB computes the following values for S1 and S2: S1 = 19.2076 S2 = 19.4646 Thus, the average energy of the signal approximately equals the average energy in the estimated spectrum.
3 Linear Model Identification Identifying Impulse-Response Models In this section...
Identifying Impulse-Response Models The response to an input u(t) is equal to the convolution of the impulse response, as follows: y(t) = t ∫0 h ( t − z) ⋅ u( z)dz Data Supported by Correlation Analysis You can estimate correlation analysis models from data with the following characteristics: • Real or complex time-domain iddata object. To learn about estimating time-series models, see Chapter 6, “Time Series Model Identification”.
3 Linear Model Identification The prewhitening filter is determined by modeling the input as an Auto-Regressive (AR) process of order N. The algorithm applies a filter of the form A(q)u(t)=u_F(t). That is, the input u(t) is subjected to an FIR filter A to produce the filtered signal u_F(t). Prewhitening the input by applying a whitening filter before estimation might improve the quality of the estimated impulse response g. The order of the prewhitening filter, N, is the order of the A filter.
Identifying Impulse-Response Models The following tables summarize the commands for computing impulse- and step-response models. The resulting models are stored as idarx model objects and contain impulse-response coefficients in the model parameter B. For detailed information about these commands, see the corresponding reference page. Commands for Impulse and Step Response Command Description Example impulse Estimates a high-order, noncausal FIR model using correlation analysis.
3 Linear Model Identification How to Compute Response Values You can use impulse and step commands with output arguments to get the numerical impulse- and step-response vectors as a function of time, respectively. To get the numerical response values: 1 Compute the FIR model by applying either impulse or step commands on the data, as described in “How to Estimate Correlation Models at the Command Line” on page 3-16.
Identifying Impulse-Response Models Step Response Plot At the command line. You can use the impulse command to plot the impulse response. The time delay is equal to the first positive peak in the transient response magnitude that is greater than the confidence region for positive time values.
3 Linear Model Identification Algorithm for Correlation Analysis To better understand the algorithm underlying correlation analysis, consider the following description of a dynamic system: y(t) = G(q)u(t) + v(t) where u(t) and y(t) are the input and output signals, respectively. v(t) is the additive noise term. G(q) is the transfer function of the system.
Identifying Impulse-Response Models q is the shift operator, defined by the following equation: G(q) = ∞ ∑ g(k)q−k q−1u(t) = u(t − 1) k=1 For impulse response, the algorithm estimates impulse response coefficients g for both the single- and multiple-output data.
3 Linear Model Identification Identifying Low-Order Transfer Functions (Process Models) In this section...
Identifying Low-Order Transfer Functions (Process Models) You can create different model structures by varying the number of poles, adding an integrator, or adding or removing a time delay or a zero. You can specify a first-, second-, or third-order model, and the poles can be real or complex (underdamped modes). Note Continuous-time process models let you estimate the input delay.
3 Linear Model Identification To estimate a low-order transfer function (process model) using the System Identification Tool GUI: 1 In the System Identification Tool GUI, select Estimate > Process models to open the Process Models dialog box. 2 If your model contains multiple inputs, select the input channel in the Input list. This list only appears when you have multiple inputs. For more information, see “Options for Multiple-Input Models” on page 3-36.
Identifying Low-Order Transfer Functions (Process Models) • Under Poles, select the number of poles, and then select All real or Underdamped. Note You need at least two poles to allow underdamped modes (complex-conjugate pair). • Select the Zero check box to include a zero, which is a numerator term other than a constant, or clear the check box to exclude the zero. • Select the Delay check box to include a delay, or clear the check box to exclude the delay.
3 Linear Model Identification Parameter table displays Auto. If you do not have a good guess for the parameter values, Auto works better than entering an ad hoc value. 5 (Optional) If you approximately know a parameter value, enter this value in the Initial Guess column of the Parameter table. The estimation algorithm uses this value as a starting point.
Identifying Low-Order Transfer Functions (Process Models) 6 In the Disturbance Model list, select one of the available options. For more information about each option, see “Options for the Disturbance Model Structure” on page 3-37. 7 In the Focus list, select how to weigh the relative importance of the fit at different frequencies. For more information about each option, see “Options for Frequency-Weighing Focus” on page 3-38.
3 Linear Model Identification To omit estimating uncertainty, select None. Skipping uncertainty computation might reduce computation time for complex models and large data sets. 10 In the Model Name field, edit the name of the model or keep the default. The name of the model should be unique in the Model Board. 11 To view the estimation progress in the MATLAB Command Window, select the Trace check box.
Identifying Low-Order Transfer Functions (Process Models) You can export the model to the MATLAB workspace for further analysis by dragging it to the To Workspace rectangle in the System Identification Tool GUI.
3 Linear Model Identification Note You can specify all property-value pairs in pem as a simple, comma-separated list without worrying about the hierarchy of these properties in the idproc model object. For more information about validating a process model, see “Overview of Model Validation and Plots” on page 8-2. You can use pem to refine parameter estimates of an existing process model, as described in “Refining Linear Parametric Models” on page 3-103.
Identifying Low-Order Transfer Functions (Process Models) Use the following commands to estimate a model m from sample data: % Load sample data load co2data % Sampling interval is 0.5 min (known) Ts = 0.5; % Split data set into estimation data ze % and validation data zv ze = iddata(Output_exp1,Input_exp1,Ts,... 'TimeUnit','min'); zv = iddata(Output_exp2,Input_exp2,Ts,...
3 Linear Model Identification Example – Estimating Process Models with Fixed Parameters at the Command Line When you know the values of certain parameters in the model and want to estimate only the values you do not know, you must specify the fixed parameters after creating the idproc model object. Use the following commands to prepare the data and construct a process model with one pole and a delay: % Load sample data load co2data % Sampling interval is 0.5 min (known) Ts = 0.
Identifying Low-Order Transfer Functions (Process Models) • status field specifies whether to estimate the parameter, or keep the initial value fixed (do not estimate), or set the value to zero. This field can have the values 'estimate', 'fixed', or 'zero'. For more information, see “Options for Initial States” on page 3-39. • min specifies the minimum bound on the parameter. • max specifies the maximum bound on the parameter. • value specifies the numerical value of the parameter, if known.
3 Linear Model Identification MATLAB computes the following result: Process model with 2 inputs: y = G_1(s)u_1 + G_2(s)u_2 where K G_1(s) = ---------- * exp(-Td*s) 1+Tp1*s with K = 12 Tp1 = 7.0998e+007 Td = 15 K G_2(s) = ---------- * exp(-Td*s) 1+Tp1*s with K = 12 Tp1 = 3.6962 Td = 3.817 In this case, the value of K is fixed at 12, but Tp1 and Td are estimated.
Identifying Low-Order Transfer Functions (Process Models) If you prefer to specify parameter constraints directly in the estimator syntax, the following table provides examples of pem commands. Action Example Fix the value of K to 12. m=pem(ze,'p1d','k','fix','k',12) Initialize K for the iterative search without fixing this value. Constrain the value of K between 3 and 4. m=pem(ze,'p1d','k',12) m=pem(ze,'p1d','k',...
3 Linear Model Identification Typically, you specify the model-structure acronym as a string argument in the estimation command pem: • pem(data,'P1D') to estimate the following structure: G(s) = K e− sTd 1 + sTp1 • pem(data,'P2ZU') to estimate the following structure: G(s) = K p (1 + sTz ) 1 + 2sζTw + s2 Tw2 • pem(data,'P0ID') to estimate the following structure: G(s) = Kp s e− sTd • pem(data,'P3Z') to estimate the following structure: G(s) = K p (1 + sTz ) (1 + sTp1 ) (1 + sTp2 ) (1 + sTp3 )
Identifying Low-Order Transfer Functions (Process Models) estimation settings for one input, select a different input in the Input Number list. If you want the same transfer function to apply to all inputs, select the Same structure for all channels check box. To apply a different structure to each channel, leave this check box clear, and create a different transfer function for each input. At the command line. Specify the model structure as a cell array of acronym strings in the estimation command pem.
3 Linear Model Identification • None — The algorithm does not estimate a noise model (C=D=1). This option also sets Focus to Simulation. • Order 1 — Estimates a noise model as a continuous-time, first-order ARMA model. • Order 2 — Estimates a noise model as a continuous-time, second-order ARMA model. At the command line. Specify the disturbance model as an argument in the estimation command pem.
Identifying Low-Order Transfer Functions (Process Models) • Stability — Behaves the same way as the Prediction option, but also forces the model to be stable. For more information about model stability, see “Unstable Models” on page 8-69. • Filter — Specify a custom filter to open the Estimation Focus dialog box, where you can enter a filter, as described in “Simple Passband Filter” on page 1-111 or “Defining a Custom Filter” on page 1-112.
3 Linear Model Identification At the command line. Specify the initial states as an argument in the estimation command pem using the same options as in the GUI. For example, use this command to estimate a first-order transfer function and set the initial states to zero: m=pem(data,'P1D','InitialState','zero') For a complete list of values for the InitialState model property, see the idproc reference page.
Identifying Input-Output Polynomial Models Identifying Input-Output Polynomial Models In this section...
3 Linear Model Identification Polynomial Model Structure You can estimate the following types of linear polynomial model structures: nu Bi (q) C(q) ui ( t − nki ) + e(t) F ( q ) D(q) i=1 i A(q) y(t) = ∑ The polynomials A, Bi, C, D, and F i contain the time-shift operator q. ui is the ith input, nu is the total number of inputs, and nki is the ith input delay that characterizes the delay response time. The variance of the white noise e(t) is assumed to be λ .
Identifying Input-Output Polynomial Models Understanding the Time-Shift Operator q The general polynomial equation is written in terms of the time-shift operator q. To understand this time-shift operator, consider the following discrete-time difference equation: y(t) + a1 y(t − T ) + a2 y(t − 2T ) = b1u(t − T ) + b2u(t − 2T ) where y(t) is the output, u(t) is the input, and T is the sampling interval.
3 Linear Model Identification information about the time-shift operator, see “Understanding the Time-Shift Operator q” on page 3-43. The following table summarizes common linear polynomial model structures supported by the System Identification Toolbox product. If you have a specific structure in mind for your application, you can decide whether the dynamics and the noise have common or different poles. A(q) corresponds to poles that are common for the dynamic model and the noise model.
Identifying Input-Output Polynomial Models Model Structure Box-Jenkins (BJ) Output-Error (OE) Discrete-Time Form nu Bi (q) C(q) ui ( t − nki ) + e(t) F (q) D(q) i=1 i y(t) = ∑ nu Bi (q) ui ( t − nki ) + e(t) F (q) i=1 i y(t) = ∑ Noise Model Provides completely independent parameterization for the dynamics and the noise using rational polynomial functions.
3 Linear Model Identification Definition of a Continuous-Time Polynomial Model In continuous time, the general frequency-domain equation is written in terms of the Laplace transform variable s, which corresponds to a differentiation operation: A(s)Y (s) = B(s) C(s) U (s) + E(s) F (s) D(s) In the continuous-time case, the underlying time-domain model is a differential equation and the model order integers represent the number of estimated numerator and denominator coefficients.
Identifying Input-Output Polynomial Models For a system with nu inputs and ny outputs, A(q) is an ny-by-ny matrix. A(q) can be represented as a polynomial in the shift operator q-1: A(q) = Iny + A1 q−1 + … + Ana q− na For more information about the time-shift operator, see “Understanding the Time-Shift Operator q” on page 3-43.
3 Linear Model Identification B(q) can also be represented as a matrix: ⎛ b11 (q) b12 (q) ⎜ b21 (q) b22 (q) B(q) = ⎜ ⎜ … … ⎜⎜ ⎝ bny1 (q) bny2 (q) … b1nu (q) ⎞ ⎟ … b2nu (q) ⎟ … … ⎟ ⎟ … bnynu( q) ⎟⎠ where the matrix element bkj is a polynomial in the shift operator q-1: bkj (q) = a1kj q − nbkj nk + … + akj kj q − nbkj − nbkj +1 nkkj is the delay from the jth input to the kth output. B(q) represents the contributions of inputs to predicting all output values.
Identifying Input-Output Polynomial Models • Single-output and multiple-output. You must import your data into the MATLAB workspace, as described in Chapter 1, “Data Processing”. Designating Data for Estimating Continuous-Time Models To get a linear, continuous-time model of arbitrary structure for time-domain data, you can estimate a discrete-time model, and then use d2c to transform it to a continuous-time model.
3 Linear Model Identification • “Estimating Model Orders at the Command Line” on page 3-53 • “Estimating Delays at the Command Line” on page 3-55 • “Selecting Model Orders from the Best ARX Structure” on page 3-55 Why Estimate Model Orders and Delays? To estimate polynomial models, you must provide input delays and model orders. If you already have insight into the physics of your system, you can specify the number of poles and zeros. In most cases, you do not know the model orders in advance.
Identifying Input-Output Polynomial Models 1 In the System Identification Tool GUI, select Estimate > Linear parametric models to open the Linear Parametric Models dialog box. The ARX model is already selected by default in the Structure list. Note For time-series models, select the AR model structure. 2 Edit the Orders field to specify a range of poles, zeros, and delays.
3 Linear Model Identification 3 Click Estimate to open the ARX Model Structure Selection window, which displays the model performance for each combination of model parameters. The following figure shows an example plot. 4 Select a rectangle that represents the optimum parameter combination and click Insert to estimates a model with these parameters. For information about using this plot, see “Selecting Model Orders from the Best ARX Structure” on page 3-55.
Identifying Input-Output Polynomial Models Estimating Model Orders at the Command Line You can estimate model orders using the struc, arxstruc, and selstruc commands in combination. If you are working with a multiple-output system, you must use struc, arxstruc, and selstruc commands for each output. In this case, you must subreference the correct output channel in your estimation and validation data sets.
3 Linear Model Identification For example, the following command uses the range of specified orders NN to compute the loss function for single-input/single-output estimation data data_e and validation data data_v: V = arxstruc(data_e,data_v,NN) Each row in NN corresponds to one set of orders: [na nb nk] selstruc. The selstruc command takes the output from arxstruc and opens the ARX Model Structure Selection window to guide your choice of the model order with the best performance.
Identifying Input-Output Polynomial Models After estimating model orders and delays, use these values as initial guesses for estimating other model structures, as described in “Using pem to Estimate Polynomial Models” on page 3-61. Estimating Delays at the Command Line The delayest command estimates the time delay in a dynamic system by estimating a low-order, discrete-time ARX model and treating the delay as an unknown parameter.
3 Linear Model Identification The horizontal axis in the ARX Model Structure Selection window is the total number of ARX parameters: Number of parameters = na + nb The vertical axis, called Unexplained output variance (in %), is the ARX model prediction error for a specific number of parameters. The prediction error is the sum of the squares of the differences between the validation data output and the model output.
Identifying Input-Output Polynomial Models • Blue minimizes Akaike AIC criterion. In the ARX Model Structure Selection window, click any bar to view the orders that give the best fit. The area on the right is dynamically updated to show the orders and delays that give the best fit. For more information about the AIC criterion, see “Using Akaike’s Criteria to Validate Models” on page 8-61.
3 Linear Model Identification 2 In the Structure list, select the polynomial model structure you want to estimate from the following options: • ARX:[na nb nk] • ARMAX:[na nb nc nk] • OE:[nb nf nk] • BJ:[nb nc nd nf nk] This action updates the options in the Linear Parametric Models dialog box to correspond with this model structure. For information about each model structure, see “What Are Black-Box Polynomial Models?” on page 3-41. Note For time-series data, only AR and ARMA models are available.
Identifying Input-Output Polynomial Models 5 In the Name field, edit the name of the model or keep the default. The name of the model should be unique in the Model Board. 6 In the Focus list, select how to weigh the relative importance of the fit at different frequencies. For more information about each option, see “Option for Frequency-Weighing Focus” on page 3-65. 7 In the Initial state list, specify how you want the algorithm to treat initial states.
3 Linear Model Identification 11 (Prediction-error method only) To stop the search and save the results after the current iteration has been completed, click Stop Iterations. To continue iterations from the current model, click the Continue iter button to assign current parameter values as initial guesses for the next search. 12 To plot the model, select the appropriate check box in the Model Views area of the System Identification Tool GUI.
Identifying Input-Output Polynomial Models m = arx(data,[na nb nk],'Property1',Value1,..., 'PropertyN',ValueN) % Using IV method m = iv4(data,[na nb nk],'Property1',Value1,..., 'PropertyN',ValueN) data is the estimation data and [na nb nk] specifies the model orders, as discussed in “What Are Black-Box Polynomial Models?” on page 3-41. The property-value pairs specify any model properties that configure the estimation algorithm and the initial conditions.
3 Linear Model Identification method gives the maximum likelihood estimate. that minimizes the prediction errors to obtain maximum-likelihood values. The resulting models are stored as idpoly model objects. Use the following general syntax to both configure and estimate polynomial models: m = pem(data,'na',na, 'nb',nb, 'nc',nc, 'nd',nb, 'nf',nc, 'nk',nk, 'Property1',Value1,..., 'PropertyN',ValueN) where data is the estimation data.
Identifying Input-Output Polynomial Models You can also model the ARARMAX structure—called the extended matrix model—by setting nf=0. The property-value pairs specify any model properties that configure the estimation algorithm and the initial conditions. You can enter all property-value pairs in pem as a comma-separated list without worrying about the hierarchy of these properties in the idpoly model object.
3 Linear Model Identification For detailed information about pem and idpoly, see the corresponding reference page. Options for Multiple-Input and Multiple-Output ARX Orders To estimate a multiple-input and multiple-output (MIMO) ARX model, you must first specify the model order matrices, as follows: • NA — An ny-by-ny matrix whose i-jth entry is the order of the polynomial that relates the jth output to the ith output.
Identifying Input-Output Polynomial Models Option for Frequency-Weighing Focus You can specify how the estimation algorithm weighs the fit at various frequencies. This information supports the estimation procedures “How to Estimate Polynomial Models in the GUI” on page 3-57 and “Using pem to Estimate Polynomial Models” on page 3-61. In the System Identification Tool GUI.
3 Linear Model Identification Options for Initial States When you use the iterative estimation algorithm PEM to estimate ARMAX, Box-Jenkins (BJ), Output-Error (OE), you must specify how the algorithm treats initial states. This information supports the estimation procedures “How to Estimate Polynomial Models in the GUI” on page 3-57 and “Using pem to Estimate Polynomial Models” on page 3-61. In the System Identification Tool GUI.
Identifying Input-Output Polynomial Models The ARX and IV algorithms treat noise differently. ARX assumes white noise. However, the instrumental variable algorithm, IV, is not sensitive to noise color. Thus, use IV when the noise in your system is not completely white and it is incorrect to assume white noise. If the models you obtained using ARX are inaccurate, try using IV. Note AR models apply to time-series data, which has no input.
3 Linear Model Identification Typically you try different model orders and compare results, ultimately choosing the simplest model that best describes the system dynamics. The following command specifies the estimation data set, z8, and the orders of the A, B, and C polynomials as na, nb, and nc, respectively. nk of [0 0 0] specifies that there is no input delay for all three input channels. m_armax=armax(z8,'na',4,... 'nb',[3 2 3],... 'nc',4,... 'nk',[0 0 0],... 'focus', 'simulation',...
Identifying Input-Output Polynomial Models 3 To view information about the resulting model object, type the following at the prompt: m_armax MATLAB returns the following information about this model object: Discrete-time IDPOLY model: A(q)y(t) = B(q)u(t) + e(t) A(q) = 1 - 1.255q^-1 + 0.2551q^-2 + 0.2948q^-3 - 0.0619q^-4 B1(q) = -0.09168 + 1.105q^-1 + 0.7399q^-2 B2(q) = 1.022 + 0.129q^-1 B3(q) = -0.07605 + 0.08681q^-1 + 0.5619q^-2 C(q) = 1-0.06117q^-1 - 0.1461q^-2 + 0.009862q^-3 - 0.
3 Linear Model Identification 4 To view all property values for this model, type the following command: get(m_armax ans = a: b: c: d: f: da: db: dc: dd: df: na: nb: nc: nd: nf: nk: InitialState: Name: Ts: InputName: InputUnit: OutputName: OutputUnit: TimeUnit: ParameterVector: PName: CovarianceMatrix: NoiseVariance: InputDelay: Algorithm: EstimationInfo: Notes: UserData: 3-70 [1 -1.2549 0.2551 0.2948 -0.0619] [3x3 double] [1 -0.0612 -0.1461 0.0099 -0.
Identifying Input-Output Polynomial Models 5 The Algorithm and EstimationInfo model properties are structures. To view the properties and values inside these structure, use dot notation. For example: m_armax.Algorithm This action displays the complete list of Algorithm properties and values that specify the iterative computational algorithm: ans = Approach: Focus: MaxIter: Tolerance: LimitError: MaxSize: SearchDirection: FixedParameter: Trace: N4Weight: N4Horizon: Advanced: 'Pem' 'Simulation' 50 1.
3 Linear Model Identification Similarly, to view the properties and values of the EstimationInfo structure, type the following command: m_armax.EstimationInfo This action displays the complete list of read-only EstimationInfo properties and values that describe the estimation data set, quantitative measures of model quality (loss function and FPE), the number of iterations actually used, and the behavior of the iterative model estimation.
Identifying State-Space Models Identifying State-Space Models In this section...
3 Linear Model Identification Definition of State-Space Models State-space models are models that use state variables to describe a system by a set of first-order differential or difference equations, rather than by one or more nth-order differential or difference equations. State variables x(t) can be reconstructed from the measured input-output data, but are not themselves measured during an experiment.
Identifying State-Space Models Discrete-Time Representation Discrete-time state-space models provide the same type of linear difference relationship between the inputs and the outputs as the linear ARX model, but are rearranged such that there is only one delay in the expressions.
3 Linear Model Identification The exact relationship between K and K is complicated. However, for short sampling intervals T, the following approximation works well: T K= ∫e Fτ τ Kd 0 State-Space Representation of Transfer Functions For linear models, the general symbolic model description is given by: y = Gu + He G is a transfer function that takes the input u to the output y. H is a transfer function that describes the properties of the additive output noise model.
Identifying State-Space Models Data Supported by State-Space Models • “Types of Supported Data” on page 3-77 • “Estimating Continuous-Time Models” on page 3-77 • “Designating Data for Estimating Discrete-Time Models” on page 3-78 Types of Supported Data You can estimate linear state-space models from data with the following characteristics: • Real data or complex data in any domain • Single-output and multiple-output • Time- or frequency-domain data To estimate state-space models for time-series data, see
3 Linear Model Identification Tip Continuous state-space models are available for canonical and structured parameterizations and grey-box models. In this case, no disturbance model can be estimated. Designating Data for Estimating Discrete-Time Models You can estimate arbitrary-order, linear state-space models for both time- or frequency-domain data. You must specify your data to have the sampling interval equal to the experimental data sampling interval.
Identifying State-Space Models You can only estimate free state-space models in discrete time. Continuous state-space models are available for canonical and structured parameterizations and grey-box models. Note To estimate canonical and structured state-space models in the System Identification Tool GUI, define the corresponding model structures at the command line and import them into the System Identification Tool GUI.
3 Linear Model Identification To estimate model orders for a specific input delay: 1 In the System Identification Tool GUI, select Estimate > Linear parametric models to open the Linear Parametric Models dialog box. 2 In the Structure list, select State Space: n [nk]. 3 Edit the Orders field to specify a range of orders for a specific delay. For example, enter the following values for n and nk: 1:10 [1] Tip As a shortcut for entering 1:10 [1], click Order Selection.
Identifying State-Space Models 5 Click Estimate to open the Model Order Selection window, which displays the relative measure of how much each state contributes to the input-output behavior of the model (log of singular values of the covariance matrix). The following figure shows an example plot. 6 Select the rectangle that represents the cutoff for the states on the left that provide a significant contribution to the input-output behavior, and click Insert to estimate a model with this order.
3 Linear Model Identification After estimating model orders, use this value as an initial guess for estimating other state-space models, as described in “How to Estimate State-Space Models in the GUI” on page 3-84. Estimating the Model Order at the Command Line You can estimate the state-space model order using the n4sid command. Use following syntax to specify the range of model orders to try for a specific input delay.
Identifying State-Space Models Using the Model Order Selection Window You can generate the Model Order Selection window for your data to select the number of states that provide the highest relative contribution to the input-output behavior of the model (log of singular values of the covariance matrix). For a procedure on generating this plot in the System Identification Tool GUI, see “Estimating Model Order in the GUI” on page 3-79.
3 Linear Model Identification smallest contribution. Based on this plot, select the rectangle that represents the cutoff for the states on the left that provide a significant contribution to the input-output behavior. The recommended choice is red. For example, in the previous figure, states 1 and 2 provide the most significant contribution. However, the contributions of the states to the right of state 2 drop significantly.
Identifying State-Space Models 1 In the System Identification Tool GUI, select Estimate > Linear parametric models to open the Linear Parametric Models dialog box. 2 In the Structure list, select State Space: n [nk]. This action updates the options in the Linear Parametric Models dialog box to correspond with this model structure. For information about each model structure, see “What Are State-Space Models?” on page 3-73.
3 Linear Model Identification 7 (PEM only) In the Initial state list, specify how you want the algorithm to treat initial states. For more information about the available options, see “Options for Initial States” on page 3-101. Tip If you get an inaccurate fit, try setting a specific method for handling initial states rather than choosing it automatically. 8 In the Covariance list, select Estimate if you want the algorithm to compute parameter uncertainties.
Identifying State-Space Models validating your model, see “Overview of Model Validation and Plots” on page 8-2. Tip You can export the model to the MATLAB workspace for further analysis by dragging it to the To Workspace rectangle in the System Identification Tool GUI.
3 Linear Model Identification 'Property1',Value1,..., 'PropertyN',ValueN) where data is the estimation data, n is the model order, and nk specifies the input delays for each input. As an alternative to pem, you can use n4sid: m = n4sid(data,n, 'nk',nk, 'Property1',Value1,..., 'PropertyN',ValueN) Note pem uses n4sid to initialize the state-space matrices. For more information about the most common property-value pairs you can specify, see “Common Properties to Specify Model Estimation” on page 3-88.
Identifying State-Space Models - “How to Estimate State-Space Models with Structured Parameterization” on page 3-93 • Focus — Specifies the frequency-weighing of the noise model during estimation. See “Options for Frequency-Weighing Focus” on page 3-100. • DisturbanceModel — Specifies to estimate or omit the noise model for time-domain data. See “K Matrix” on page 3-89. • InitialStates — Specifies to set or estimate the initial states. See “Options for Initial States” on page 3-101.
3 Linear Model Identification For frequency-domain data, no noise model is estimated and K is set to 0. For time-domain data, K is estimated by default. To modify whether K is estimated for time-domain data, you can specify the DisturbanceModel property in the estimator syntax. Initially, you can omit estimating the noise parameters in K to focus on achieving a reasonable model for the system dynamics.
Identifying State-Space Models routines. Because the parameterization of A, B, and C is free, a basis for the state-space realization is automatically selected to give well-conditioned calculations. You can only estimate discrete-time state-space models with any parameterization. Continuous state-space models are available for canonical and structured parameterizations only. To estimate the disturbance model K, you must use time domain data.
3 Linear Model Identification matrices A, B, C, and D, and the remaining matrix elements are fixed to zeros and ones. Of the two popular canonical forms, which include controllable canonical form and observable canonical form, the toolbox supports only controllable forms. Controllable canonical structures include free parameters in output rows of the A matrix, free B and K matrices, and the fixed C matrix.
Identifying State-Space Models You can specify additional property-value pairs similar to the free-parameterization case, as described in “How to Estimate Free-Parameterization State-Space Models” on page 3-90. For information about validating your model, see “Overview of Model Validation and Plots” on page 8-2.
3 Linear Model Identification This approach differs from estimating models with free and canonical parameterizations, where it is not necessary to specify initial parameter values before the estimation. For free parameterization, there is no structure to specify because it is assumed to be unknown. For canonical parameterization, the structure is fixed to a specific form. For information about validating your model, see “Overview of Model Validation and Plots” on page 8-2.
Identifying State-Space Models Specify the structure matrix values, as follows: • Set a NaN value to flag free parameters at the corresponding locations in A, B, C, D, K, and x0. • Specify the values of fixed parameters at the corresponding locations in A, B, C, D, K, and x0. For example, suppose that you constructed a nominal state-space model m with the following A matrix: A = [2 0; 0 3] Suppose you want to fix A(1,2)=A(2,1)=0.
3 Linear Model Identification Are Grey-Box Models Similar to State-Space Models with Structured Parameterization? Structured parameterization state-space models are similar to grey-box modeling. However, the state-space models are simpler to estimate than grey-box models. To learn more about grey-box models, see Chapter 5, “ODE Parameter Estimation (Grey-Box Modeling)”.
Identifying State-Space Models C = [1,0]; D = 0; K = [4;5]; 2 Construct the state-space model object: m = idss(A,B,C,D,K); 3 Specify the parameter values in the structure matrices that you do not want to estimate: m.As = [1, NaN; 0 ,1]; m.Bs = [NaN;NaN]; m.Cs = [1, 0]; m.Ds = 0; m.Ks = [NaN;NaN]; m.x0s = [0;0]; 4 Estimate the model structure: m = pem(data,m) where data is name of the iddata object containing time-domain or frequency-domain data.
3 Linear Model Identification This equation represents an electrical motor, where y1 (t) = x1 (t) is the angular position of the motor shaft, and y2 (t) = x2 (t) is the angular velocity. The parameter −θ1 is the inverse time constant of the motor, and − θ2 θ is the 1 static gain from the input to the angular velocity. The motor is at rest at t=0, but its angular position θ3 is unknown. Suppose that the approximate nominal values of the unknown parameters are θ1 = −1 and θ2 = 0.25 .
Identifying State-Space Models K = zeros(2,2); x0 = [0;0]; 2 Construct the continuous-time state-space model object: m = idss(A,B,C,D,K,x0,'Ts',0); 3 Specify the parameter values in the structure matrices that you do not want to estimate: m.As = [0 1;0 NaN]; m.Bs = [0;NaN]; m.Cs = m.c; m.Ds = m.d; m.Ks = m.k; m.x0s = [NaN;0] m.NoiseVariance = [0.01 0; 0 0.1]; 4 Estimate the model structure: m = pem(data,m) where data is name of the iddata object containing time-domain or frequency-domain data.
3 Linear Model Identification How to Estimate the State-Space Equivalent of ARMAX and OE Models You can estimate the equivalent of ARMAX and output-error (OE) multiple-output models using state-space model structures. For the ARMAX case, specify to estimate the K matrix for the state-space model. For the OE case, set K to zero. For more information about ARMAX and OE models, see “Identifying Input-Output Polynomial Models” on page 3-41.
Identifying State-Space Models At the command line. Specify the focus as an argument in the model-estimation command using the same options as in the GUI. For example, use this command to emphasize the fit between the 5 and 8 rad/s: pem(data,4,'Focus',[5 8]) Options for Initial States If you estimate state-space models using the iterative estimation algorithm pem, you must specify how the algorithm treats initial states.
3 Linear Model Identification the n4sid reference page), and then try to refine the initial estimate using the iterative prediction-error method PEM (see the pem reference page). N4SID is faster than PEM, but is typically less accurate and robust, and requires additional arguments that might be difficult to specify. You can use the iterative prediction-error minimization (PEM) (maximum likelihood) algorithm for all linear and nonlinear model types.
Refining Linear Parametric Models Refining Linear Parametric Models In this section... “When to Refine Models” on page 3-103 “What You Specify to Refine a Model” on page 3-103 “How to Refine Linear Parametric Models in the GUI” on page 3-104 “How to Refine Linear Parametric Models at the Command Line” on page 3-105 When to Refine Models There are two situations where you can refine estimates of linear parametric models.
3 Linear Model Identification How to Refine Linear Parametric Models in the GUI The following procedure assumes that the model you want to refine is already in the System Identification Tool GUI. You might have estimated this model in the current session or imported the model from the MATLAB workspace. For information about importing models into the GUI, see “Importing Models into the GUI” on page 12-9.
Refining Linear Parametric Models 7 Validate the new model, as described in Chapter 8, “Model Analysis”. Tip To continue refining the model using additional iterations, click Continue iter. This action continues parameter estimation using the most recent model. How to Refine Linear Parametric Models at the Command Line If you are working at the command line, you can use pem to refine parametric model estimates.
3 Linear Model Identification Example – Refining an Initial ARMAX Model at the Command Line The following example shows to estimate an initial model and try to refine this model using pem: load iddata8 % Split the data z8 into two parts.
Refining Linear Parametric Models Example – Refining an ARMAX Model with Initial Parameter Guesses at the Command Line The following example shows how to refine models for which you have initial parameter guesses. This example estimates an ARMAX model for the data and requires you to initialize the A, B, and C polynomials. In this case, you must first create a model object and set the initial parameter values in the model properties.
3 Linear Model Identification Extracting Parameter Values from Linear Models You can extract the numerical parameter values and uncertainties of model objects and store these values using double data format. For example, you can extract state-space matrices for state-space models, and extract polynomials for polynomial models. You can operate on extracted model data as you would on any other MATLAB vectors and matrices.
Extracting Parameter Values from Linear Models Commands for Extracting Numerical Model Data (Continued) Command Description freqresp Extracts frequency-response data from any idmodel or idfrd object. polydata ssdata tfdata zpkdata Extracts polynomials from any single-output idmodel object. Extracts state-space matrices from any idmodel object. Syntax [H,w,CovH] = freqresp(m) [A,B,C,D,F,dA,dB,dC,dD,dF] = ... polydata(m) [A,B,C,D,K,X0,... dA,dB,dC,dD,dK,dX0] = ...
3 Linear Model Identification Extracting Dynamic Model and Noise Model Separately You can extract the numerical data associated with a dynamic model and the noise model separately. For linear models, the general symbolic model description is given by: y = Gu + He G is an operator that takes the measured inputs u to the outputs and captures the system dynamics.
Extracting Dynamic Model and Noise Model Separately Syntax for Extracting Transfer-Function Data (Continued) Command Syntax fcn(noisecnv(m,'Norm')) Returns the properties of [G HL] ny outputs and ny+nu inputs. fcn(noisecnv(m('noise'),'Norm')) Returns the properties of HL ny outputs and ny inputs. fcn(m) If m is a time-series model, returns the properties of H. fcn(noisecnv(m,'Norm')) If m is a time-series model, returns the properties of HL.
3 Linear Model Identification Transforming Between Discrete-Time and Continuous-Time Representations In this section...
Transforming Between Discrete-Time and Continuous-Time Representations Note c2d and d2d correctly approximate the transformation of the noise model when the sampling interval T is small compared to the bandwidth of the noise. Command Description Usage Example c2d Converts continuous-time models to discrete-time models. To transform a continuous-time model mod_c to a discrete-time form, use the following command: mod_d = c2d(mod_c,T) where T is the sampling interval of the discrete-time model.
3 Linear Model Identification The following commands compare estimated model m and its continuous-time counterpart mc on a Bode plot: % Estimate discrete-time ARMAX model % from the data m = armax(data,[2 3 1 2]); % Convert to continuous-time form mc = d2c(m); % Plot bode plot for both models bode(m,mc) Specifying Intersample Behavior A sampled signal is characterized only by its values at the sampling instants.
Transforming Between Discrete-Time and Continuous-Time Representations A delay in the discrete-time model that corresponds to an actual delay in the continuous-time model is stored in the in the InputDelay property of the resulting continuous-time model. Typically, this InputDelay is (nk-1)/Ts, where nk is the delay of the discrete-time system and Ts is the sampling interval.
3 Linear Model Identification underlying continuous-time model being subject to continuous-time white noise disturbances, which have infinite, instantaneous variance. In this case, the underlying continuous-time model is the unique representation for discrete-time models. To maintain the same level of noise after interpolating the noise signal, scale the noise spectrum by TNew T , where Tnew is the new Old sampling interval and Told is the original sampling interval. before applying sim.
Transforming Between Linear Model Representations Transforming Between Linear Model Representations You can transform linear models between state-space and polynomial forms. You can also transform between frequency-response, state-space, and polynomial forms. If you used the System Identification Tool GUI to estimate models, you must export the models to the MATLAB workspace before converting models. For detailed information about each command in the following table, see the corresponding reference page.
3 Linear Model Identification Commands for Transforming Model Representations (Continued) Command Model Type to Convert Usage Example idpoly Converts single-output idmodel object to ARMAX representation. If you have the Control System Toolbox product, this command converts any single-output LTI object except frd. To get an ARMAX model from state-space model m_ss, use the following command: Converts any single- or multiple-output idmodel object to state-space representation.
Subreferencing Model Objects Subreferencing Model Objects In this section... “What Is Subreferencing?” on page 3-119 “Limitation on Supported Models” on page 3-119 “Subreferencing Specific Measured Channels” on page 3-119 “Subreferencing Measured and Noise Models” on page 3-120 “Treating Noise Channels as Measured Inputs” on page 3-122 What Is Subreferencing? You can use subreferencing to create models with subsets of inputs and outputs from existing multivariable models.
3 Linear Model Identification To select all output or all input channels, use a colon (:). To select no channels, specify an empty matrix ([]). If you need to reference several channel names, use a cell array of strings.
Subreferencing Model Objects Thus, linear, parametric models represent input-output relationships for two kinds of input channels: measured inputs and (unmeasured) noise inputs. For example, consider the ARX model given by one of the following equations: A(q) y(t) = B(q)u ( t − nk ) + e(t) or y(t) = B(q) 1 u(t) + e(t) A(q) A(q) In this case, the dynamic model is the relationship between the measured input u and output y, G = B( q) A( q) .
3 Linear Model Identification To create a new model by subreferencing H due to unmeasured inputs, use the following syntax: m_H = m('noise') Tip Alternatively, you can use the following shorthand syntax: m_H = m('n') This operation creates a time-series model from m by ignoring the measured input.
Subreferencing Model Objects Converting noise channels to measured inputs loses information about the variance of the innovations e. For example, step response due to the noise channels does not take into consideration the magnitude of the noise contributions.
3 Linear Model Identification Concatenating Model Objects In this section...
Concatenating Model Objects Horizontal Concatenation of Model Objects Horizontal concatenation of model objects requires that they have the same outputs. If the output channel names are different and their dimensions are the same, the concatenation operation uses the names of output channels in the first model object you listed. Input channels must have unique names. The following syntax creates a new model object m that contains the horizontal concatenation of m1,m2,...,mN: m = [m1,m2,...
3 Linear Model Identification Note You cannot concatenate the single-output idproc and idpoly model objects. The following syntax creates a new model object m that contains the vertical concatenation of m1,m2,...,mN: m = [m1;m2;... ;mN] m takes the same inputs in the original models to all of the output of m1,m2,...,mN. The following diagram is a graphical representation of vertical concatenation of frequency-response data.
Concatenating Model Objects When the SpectralData property of individual idfrd objects is not empty, horizontal and vertical concatenation handle SpectralData, as follows. In case of horizontal concatenation, there is no meaningful way to combine the SpectralData of individual idfrd objects, and the resulting SpectralData property is empty. An empty property results because each idfrd object has its own set of noise channels, where the number of noise channels equals the number of outputs.
3 Linear Model Identification Merging Model Objects You can merge models of the same structure to obtain a single model with parameters that are statistically weighed means of the parameters of the individual models. When computing the merged model, the covariance matrices of the individual models determine the weights of the parameters. You can perform the merge operation for the idarx, idgrey, idpoly, idproc, and idss model objects. Note Each merge operation merges the same type of model object.
4 Nonlinear Black-Box Model Identification • “Supported Data for Estimating Nonlinear Black-Box Models” on page 4-2 • “Supported Nonlinear Black-Box Models” on page 4-3 • “Identifying Nonlinear ARX Models” on page 4-4 • “Identifying Hammerstein-Wiener Models” on page 4-15 • “Supported Nonlinearity Estimators” on page 4-25 • “Refining Nonlinear Black-Box Models” on page 4-28 • “Extracting Parameter Values from Nonlinear Black-Box Models” on page 4-30 • “Next Steps After Estimating Nonlinear Black-Box Models”
4 Nonlinear Black-Box Model Identification Supported Data for Estimating Nonlinear Black-Box Models You can estimate discrete-time black-box models for data with the following characteristics: • Time-domain input-output or time-series data. Note Time series are supported for nonlinear ARX models only. • Single-output or multiple-output data.
Supported Nonlinear Black-Box Models Supported Nonlinear Black-Box Models You can estimate the following types of nonlinear black-box models: • Nonlinear ARX models • Hammerstein-Wiener models You can estimate these models both in the System Identification Tool GUI and at the command line. For an introduction, see “Tutorial – Identifying Nonlinear Black-Box Models Using the GUI” in the System Identification Toolbox Getting Started Guide.
4 Nonlinear Black-Box Model Identification Identifying Nonlinear ARX Models In this section...
Identifying Nonlinear ARX Models The predicted output yˆ (t) of a nonlinear model at time t is given by the following general equation: yˆ (t) = F ( x(t)) where x(t) represents the regressors. F is a nonlinear regression function, which is approximated by a nonlinearity estimator, which might be a binary partition tree, a neural network, or a network based on wavelets. The following figure shows how the predicted output of the model is formed from the inputs and outputs.
4 Nonlinear Black-Box Model Identification For more information about regressors, see “Using Regressors” on page 4-6. For a list of nonlinearity estimators supported by nonlinear ARX models, see “Nonlinearity Estimators for Nonlinear ARX Models” on page 4-9. Using Regressors You can use the following types of regressors for nonlinear ARX models: • Standard regressors — Past input u(t) and output signals y(t), computed automatically as delay transformations for specified model orders.
Identifying Nonlinear ARX Models Example – Relationship Between Regressors, Model Orders, and Delays This example describes how the model orders and delays you specify relate to computing the regressors. Suppose that you specify a nonlinear ARX model with a minimum of a two-sample input delay and the number of input terms is nb=2.
4 Nonlinear Black-Box Model Identification Using Custom Regressors In general, custom regressors are nonlinear functions of delayed input and output data samples. You can specify custom regressors, such as tan(u(t-1)), u(t-1)2, or u(t-1)*y(t-3). In the System Identification Tool GUI. You can create custom regressors in the Model Regressors dialog box. For more information, see “How to Estimate Nonlinear ARX Models in the GUI” on page 4-10. At the command line.
Identifying Nonlinear ARX Models Nonlinearity Estimators for Nonlinear ARX Models Nonlinear ARX models support the following nonlinearity estimators: • Sigmoid Network • Tree Partition • Wavelet Network • Custom Network • Linear (indicates absence of nonlinearity estimator) • Neural Network Note You must have the Neural Network Toolbox™ product to use the Neural Network nonlinearity estimator.
4 Nonlinear Black-Box Model Identification How to Estimate Nonlinear ARX Models in the GUI You must have already imported your data into the System Identification Tool GUI. For more information about preparing your data, see Chapter 1, “Data Processing”. To estimate a nonlinear ARX model in the System Identification Tool GUI: 1 In the System Identification Tool GUI, select Estimate > Nonlinear models to open the Nonlinear Models dialog box. The Model Type tab is selected.
Identifying Nonlinear ARX Models • In the Regressors tab, change the input delay of the input signals. To gain insight into possible input delay values, click Infer Input Delay. This action opens the Infer Input Delay dialog box. • In the Regressors tab, change the number of terms to include in the nonlinear block. • In the Regressors tab, click Edit Regressors to select which regressors are included in the nonlinear block. This action opens the Model Regressors dialog box.
4 Nonlinear Black-Box Model Identification General nlarx Syntax You can estimate nonlinear ARX models using nlarx. The resulting models are stored as idnlarx model objects. Use the following general syntax to both configure and estimate nonlinear ARX models: m = nlarx(data,'na',na,... 'nb',nb,... 'nk',nk,... Nonlinearity,... 'Property1',Value1,..., 'PropertyN',ValueN) where data is the estimation data. na, nb, and nk specify the model orders and delays.
Identifying Nonlinear ARX Models For detailed information about the nlarx and idnlarx properties and values, see the corresponding reference page. For more information about validating models, see Chapter 8, “Model Analysis”. Note You do not need to construct the model object using idnlarx before estimation. You can also use pem to refine parameter estimates of an existing nonlinear ARX model, as described in “Refining Nonlinear Black-Box Models” on page 4-28.
4 Nonlinear Black-Box Model Identification Compare the resulting models by plotting the model outputs on top of the measured output: compare(zv, m1,m2,m3,m4,m5) MATLAB software responds with the following plot.
Identifying Hammerstein-Wiener Models Identifying Hammerstein-Wiener Models In this section...
4 Nonlinear Black-Box Model Identification The input signal passes through the first nonlinear block, a linear block, and a second nonlinear block to produce the output signal, as shown in the following figure.
Identifying Hammerstein-Wiener Models If only the input nonlinearity is present, the model is called a Hammerstein model. If only the output nonlinearity is present, the model is called a Wiener model. You must specify the following model orders for the linear block: • nb—The number of zeros plus one. • nf—The number of poles. • nk—The delay from input to the output in terms of the number of samples. For ny outputs and nu inputs, nb, nf, and nk are ny-by-nu matrices.
4 Nonlinear Black-Box Model Identification In the System Identification Tool GUI. Exclude a nonlinearity for a specific channel by selecting None. At the command line. Exclude a nonlinearity for a specific channel by specifying the unitgain value for the InputNonlinearity or OutputNonlinearity properties. For more information about estimation objects and their properties, see nlhw and idnlhw reference page.
Identifying Hammerstein-Wiener Models 4 (Optional) If you want to try refining a previously estimated model, select the name of this model in the Initial model list. Note The model structure and algorithm properties of the initial model populate the fields in the Nonlinear Models dialog box. A model is available in the Initial model list under the following conditions: • The model exists in the System Identification Tool GUI.
4 Nonlinear Black-Box Model Identification 7 To plot the response of this model, select the appropriate check box in the Model Views area of the System Identification Tool GUI. For more information about working with plots and validating models, see Chapter 8, “Model Analysis”. If you get an inaccurate fit, try estimating a new model with different orders or nonlinearity estimator.
Identifying Hammerstein-Wiener Models information about model orders, see “Definition of the Hammerstein-Wiener Model” on page 4-15. InputNonlinearity specifies the input static nonlinearity estimator object as 'pwlinear', 'deadzone', 'saturation', 'sigmoidnet', 'wavenet', 'customnet', 'unitgain', or 'poly1d'. Similarly, OutputNonlinearity specifies the output static nonlinearity estimator object. The property-value pairs specify any idnlhw model properties that configure the estimation algorithm.
4 Nonlinear Black-Box Model Identification You can specify different nonlinearity estimators for different output channels by setting InputNonlinearity or OutputNonlinearity to an object array. For example, the following code estimates a two-input Hammerstein-Wiener model, where sigmoidnet and pwlinear are the two input nonlinearities and there is no output nonlinearity: m = nlhw(data,[nb,nf,nk],... [sigmoidnet;pwlinear],...
Identifying Hammerstein-Wiener Models Example – Using nlhw to Estimate Hammerstein-Wiener Models This example uses nlhw to estimate a Hammerstein-Wiener model for the two-tank system. The data for this system is described in “Tutorial – Identifying Nonlinear Black-Box Models Using the GUI” in the System Identification Toolbox Getting Started Guide. Prepare the data for estimation using the following commands: load twotankdata z = iddata(y, u, 0.
4 Nonlinear Black-Box Model Identification MATLAB software responds with the following plot.
Supported Nonlinearity Estimators Supported Nonlinearity Estimators In this section... “Types of Nonlinearity Estimators” on page 4-25 “Creating Custom Nonlinearities” on page 4-26 Types of Nonlinearity Estimators When configuring the nonlinear ARX and Hammerstein-Wiener models for estimation, you must specify a mathematical structure for the nonlinear portion of the model.
4 Nonlinear Black-Box Model Identification Nonlinearity Object Name Supported Model Type Supports Multiple Inputs? Tree Partition treepartition Nonlinear ARX Yes Wavelet Network wavenet Hammerstein-Wiener and Nonlinear ARX Yes The Neural Network nonlinearity lets you import a network object you created using the Neural Network Toolbox commands. The nonlinearity estimators deadzone, poly1d, pwlinear, and saturation are optimized for estimating Hammerstein-Wiener models.
Supported Nonlinearity Estimators % % % % % % % % g: df/dx a: unit active range (g(x) is significantly nonzero in the interval [-a a]) The unit function must be vectorized: for a vector or matrix x, the output arguments f and g must have the same size as x f and g are computed element by element. f = exp(-x.*x); if nargout>1 g = - 2*x .* f; a = 0.
4 Nonlinear Black-Box Model Identification Refining Nonlinear Black-Box Models In this section... “How to Refine Nonlinear Black-Box Models in the GUI” on page 4-28 “How to Refine Nonlinear Black-Box Models at the Command Line” on page 4-29 How to Refine Nonlinear Black-Box Models in the GUI The following procedure assumes that the model you want to refine is already in the System Identification Tool GUI.
Refining Nonlinear Black-Box Models 4 Click Estimate to refine the model. 5 Validate the new model, as described in Chapter 8, “Model Analysis”. Tip To continue refining the model directly from the Estimation tab, select the Use last estimated model as initial model for the next estimation check box, and click Estimate. This action automatically selects the most recent model in the Initial model list in the Model Type tab.
4 Nonlinear Black-Box Model Identification Extracting Parameter Values from Nonlinear Black-Box Models In this section... “Nonlinear ARX Parameter Values” on page 4-30 “Hammerstein-Wiener Parameter values” on page 4-31 Nonlinear ARX Parameter Values You can extract the numerical parameter values of a nonlinear ARX model by accessing the properties of the idnlarx model object.
Extracting Parameter Values from Nonlinear Black-Box Models Hammerstein-Wiener Parameter values You can extract the numerical parameter values of a Hammerstein-Wiener model by accessing the properties of the idnlhw model object. The Hammerstein-Wiener model parameter you might want to explore include model orders and delays, nonlinearity estimator parameters, and the properties of the linear model.
4 Nonlinear Black-Box Model Identification Next Steps After Estimating Nonlinear Black-Box Models After estimating nonlinear black-box models, you can perform the following operations: • View parameter values, standard deviations of the parameters, loss function, and Akaike’s Final Prediction Error (FPE) Criterion at the command line using the present command or by get the EstimationInfo property of the model. • Simulate the model using the sim command.
Computing Linear Approximations of Nonlinear Black-Box Models Computing Linear Approximations of Nonlinear Black-Box Models In this section...
4 Nonlinear Black-Box Model Identification state values. For more information, see “Tangent Linearization of Nonlinear Black-Box Models” on page 4-35. Linear Approximation of Nonlinear Black-Box Models for a Given Input linapp computes the best linear approximation—in a mean-square-error sense—of a nonlinear ARX or Hammerstein-Wiener model for a given input or a randomly generated input.
Computing Linear Approximations of Nonlinear Black-Box Models Tangent Linearization of Nonlinear Black-Box Models linearize computes a first-order Taylor series approximation for nonlinear system dynamics about and operating point, which is defined by a constant input and model state values. To compute a tangent linear approximation of a nonlinear black-box model, you must have the following variables in the MATLAB workspace: • Nonlinear ARX (idnlarx) or Hammerstein-Weiner (idnlhw) model.
4 Nonlinear Black-Box Model Identification • “Computing Operating Points at a Simulation Snapshot” on page 4-36 Computing Operating Point from Steady-State Specifications You can compute an operating point from steady-state specifications, as follows: • Using values of input and output signals. If either the steady-state input or output value is unknown, you can specify it as NaN to estimate this value.
Computing Linear Approximations of Nonlinear Black-Box Models can compute them using the findstates command. For more information, see the findstates(idnlarx) or findstates(idnlhw) reference pages.
4 4-38 Nonlinear Black-Box Model Identification
5 ODE Parameter Estimation (Grey-Box Modeling) • “Supported Grey-Box Models” on page 5-2 • “Data Supported by Grey-Box Models” on page 5-3 • “Choosing idgrey or idnlgrey Model Object” on page 5-4 • “Estimating Linear Grey-Box Models” on page 5-6 • “Estimating Nonlinear Grey-Box Models” on page 5-16 • “After Estimating Grey-Box Models” on page 5-23
5 ODE Parameter Estimation (Grey-Box Modeling) Supported Grey-Box Models If you understand the physics of your system and can represent the system using ordinary differential or difference equations (ODEs) with unknown parameters, then you can use System Identification Toolbox commands to perform linear or nonlinear grey-box modeling. Grey-box model ODEs specify the mathematical structure of the model explicitly, including couplings between parameters and known parameter values.
Data Supported by Grey-Box Models Data Supported by Grey-Box Models You can estimate both continuous-time or discrete-time grey-box models for data with the following characteristics: • Time-domain or frequency-domain data, including time-series data with no inputs. Note Nonlinear grey-box models support only time-domain data. • Single-output or multiple-output data You must first import your data into the MATLAB workspace.
5 ODE Parameter Estimation (Grey-Box Modeling) Choosing idgrey or idnlgrey Model Object Grey-box models require that you specify the structure of the ODE model in a file. You use this file to create the idgrey or idnlgrey model object. You can use both the idgrey and the idnlgrey objects to model linear systems. However, you can only represent nonlinear dynamics using the idnlgrey model object.
Choosing idgrey or idnlgrey Model Object Comparison of idgrey and idnlgrey Objects (Continued) Settings and Operations Supported by idgrey? Supported by idnlgrey? Honor stability constraints specified by Yes No Algorithm.Advanced. Threshold.Zstability Note If you know the parameter bounds for obtaining a stable idnlgrey model, set these bounds to ensure stability. and Algorithm.Advanced. Threshold.
5 ODE Parameter Estimation (Grey-Box Modeling) Estimating Linear Grey-Box Models In this section...
Estimating Linear Grey-Box Models The first step in grey-box modeling is to write an M-file that returns state-space matrices as a function of user-defined parameters and information about the model.
5 ODE Parameter Estimation (Grey-Box Modeling) This equation represents an electrical motor, where y1 (t) = x1 (t) is the angular position of the motor shaft, and y2 (t) = x2 (t) is the angular velocity. The parameter −θ1 is the inverse time constant of the motor, and − θ2 θ is the 1 static gain from the input to the angular velocity. The motor is at rest at t=0, but its angular position θ3 is unknown. Suppose that the approximate nominal values of the unknown parameters are θ1 = −1 and θ2 = 0.25 .
Estimating Linear Grey-Box Models 2 Use the following syntax to define an idgrey model object based on the myfunc M-file: m = idgrey('myfunc',par,'c',T,aux) where par represents user-defined parameters and contains their nominal (initial) values. 'c' specifies that the underlying parameterization is in continuous time. aux contains the values of the auxiliary parameters. Note You must specify T and aux even if they are not used by the myfunc code.
5 ODE Parameter Estimation (Grey-Box Modeling) Under ideal conditions, this system is described by the heat-diffusion equation—which is a partial differential equation in space and time.
Estimating Linear Grey-Box Models The following M-file describes the state-space equation for this model. In this case, the auxiliary variables specify grid-size variables, so that you can modify the grid size without the M-file.
5 ODE Parameter Estimation (Grey-Box Modeling) Use the following syntax to define an idgrey model object based on the heatd M-file: m = idgrey('heatd',[0.27 1],'c',[10,1,22]) This command specifies the auxiliary parameters as inputs to the function, include the model order 10, the rod length of 1 meter, and an initial temperature of 22 degrees Celsius. The command also specifies the initial values for heat conductivity as 0.27, and for the heat transfer coefficient as 1.
Estimating Linear Grey-Box Models Description of the SISO System This example is based on a discrete, single-input and single-output (SISO) system represented by the following state-space equations: ⎡1 ⎤ ⎡ par1 par 2⎤ x(kT + T ) = ⎢ x(kT ) + ⎢ ⎥ u(kT ) + w(kT ) ⎥ 0 ⎦ ⎣0 ⎦ ⎣ 1 y(kT ) = [ par 3 par 4 ] x(kT ) + e(kT ) x(0) = x0 where w and e are independent white-noise terms with covariance matrices R1 and R2, respectively. R1=E{ww’} is a 2–by-2 matrix and R2=E{ee’} is a scalar.
5 ODE Parameter Estimation (Grey-Box Modeling) 1 Create the M-file mynoise that computes the state-space matrices as a function of the five unknown parameters and the auxiliary variable that represents the known variance R2. Note R2 is treated as an auxiliary variable rather than assigned a value in the M-file to let you change this value directly at the command line and avoid editing the M-file.
Estimating Linear Grey-Box Models Model = pem(data,Minit) 5-15
5 ODE Parameter Estimation (Grey-Box Modeling) Estimating Nonlinear Grey-Box Models In this section...
Estimating Nonlinear Grey-Box Models Specifying the Nonlinear Grey-Box Model Structure You must represent your system as a set of first-order nonlinear difference or differential equations: x† (t) = F (t, x(t), u(t), par1, par 2,..., parN ) y(t) = H (t, x(t), u(t), par1, par 2,..., parN ) + e(t) x(0) = x0 where x† (t) = dx(t) dt for continuous-time representation and x† (t) = x(t + Ts ) for discrete-time representation with Ts as the sampling interval.
5 ODE Parameter Estimation (Grey-Box Modeling) • y — Represents the right side(s) of the output equation(s). A column vector with Ny entries. The file inputs are: • t — Current time. • x — State vector at time t. For static models, equals []. • u — Input vector at time t. For time-series models, equals []. • p1,p2, ...,pN — Parameters, which can be real scalars, column vectors or two-dimensional matrices. N is the number of parameter objects.
Estimating Nonlinear Grey-Box Models • Order — Vector with three entries [Ny Nu Nx], specifying the number of model outputs Ny, the number of inputs Nu, and the number of states Nx. • Parameters — Parameters, specified as struct arrays, cell arrays, or double arrays. • InitialStates — Specified in the same way as parameters. Must be the fourth input to the idnlgrey constructor. For detailed information about this object and its properties, see the idnlgrey reference page.
5 ODE Parameter Estimation (Grey-Box Modeling) Options for the Estimation Algorithm The Algorithm property of the model specifies the estimation algorithm, which simulates the model several times by trying various parameter values to reduce the prediction error.
Estimating Nonlinear Grey-Box Models One category of methods consists of the minimization schemes that are based on line-search methods, including Gauss-Newton type methods, steepest-descent methods, and Levenberg-Marquardt methods. The Trust-Region Reflective Newton method of nonlinear least-squares (lsqnonlin), where the cost is the sum of squares of errors between the measured and simulated outputs, requires Optimization Toolbox™ software.
5 5-22 ODE Parameter Estimation (Grey-Box Modeling)
After Estimating Grey-Box Models After Estimating Grey-Box Models After estimating linear and nonlinear grey-box models, you can simulate the model output using the sim command. For more information, see Chapter 9, “Simulation and Prediction”. The toolbox represents linear grey-box models using the idgrey model object. To convert grey-box models to state-space form, use the idss command, as described in “Transforming Between Linear Model Representations” on page 3-117.
5 5-24 ODE Parameter Estimation (Grey-Box Modeling)
6 Time Series Model Identification • “What Are Time-Series Models?” on page 6-2 • “Preparing Time-Series Data” on page 6-3 • “Estimating Time-Series Power Spectra” on page 6-4 • “Estimating AR and ARMA Models” on page 6-7 • “Estimating State-Space Time-Series Models” on page 6-12 • “Example – Identifying Time-Series Models at the Command Line” on page 6-14 • “Estimating Nonlinear Models for Time-Series Data” on page 6-15
6 Time Series Model Identification What Are Time-Series Models? A time series is one or more measured output channels with no measured input. You can estimate time-series spectra using both time- and frequency-domain data. Time-series spectra describe time-series variations using cyclic components at different frequencies. You can also estimate parametric autoregressive (AR), autoregressive and moving average (ARMA), and state-space time-series models.
Preparing Time-Series Data Preparing Time-Series Data Before you can estimate models for time-series data, you must import your data into the MATLAB software. You can estimate models from either time-domain and frequency-domain data. For information about which variables you need to represent time-series data, see “Importing Time-Series Data into MATLAB” on page 1-7. For more information about preparing data for modeling, see “Ways to Process Data for System Identification” on page 1-2.
6 Time Series Model Identification Estimating Time-Series Power Spectra In this section... “How to Estimate Time-Series Power Spectra Using the GUI” on page 6-4 “How to Estimate Time-Series Power Spectra at the Command Line” on page 6-5 How to Estimate Time-Series Power Spectra Using the GUI You must have already imported your data into the GUI, as described in “Preparing Time-Series Data” on page 6-3.
Estimating Time-Series Power Spectra For time-domain data, the frequency ranges from 0 to the Nyquist frequency. For frequency-domain data, the frequency ranges from the smallest to the largest frequency in the data set. 4 In the Frequency Resolution field, enter the frequency resolution, as described in “Options for Frequency Resolution” on page 3-6. To use the default value, enter default or leave the field empty. 5 In the Model Name field, enter the name of the correlation analysis model.
6 Time Series Model Identification Estimating Frequency Response of Time Series Command Description etfe Estimates a periodogram using Fourier analysis. spa Estimates the power spectrum with its standard deviation using spectral analysis. spafdr Estimates the power spectrum with its standard deviation using a variable frequency resolution. For example, suppose y is time-series data.
Estimating AR and ARMA Models Estimating AR and ARMA Models In this section... “Definition of AR and ARMA Models” on page 6-7 “Estimating Polynomial Time-Series Models in the GUI” on page 6-7 “Estimating AR and ARMA Models at the Command Line” on page 6-10 Definition of AR and ARMA Models For a single-output signal y(t), the AR model is given by the following equation: A(q) y(t) = e(t) The AR model is a special case of the ARX model with no input.
6 Time Series Model Identification • (Multiple-output AR models only) Specified the model-order matrix in the MATLAB workspace before estimation, as described in “Options for Multiple-Input and Multiple-Output ARX Orders” on page 3-64 To estimate AR and ARMA models using the System Identification Tool GUI: 1 In the System Identification Tool GUI, select Estimate > Linear parametric models to open the Linear Parametric Models dialog box.
Estimating AR and ARMA Models 4 (AR models only) Select the estimation Method as ARX or IV (instrumental variable method). For more information about these methods, see “Algorithms for Estimating Polynomial Models” on page 3-66. Note IV is not available for multiple-output data. 5 In the Name field, edit the name of the model or keep the default. The name of the model should be unique in the Model Board. 6 In the Initial state list, specify how you want the algorithm to treat initial states.
6 Time Series Model Identification • Fit improvements — Shows the actual versus expected improvements in the fit. 9 Click Estimate to add this model to the Model Board in the System Identification Tool GUI. 10 (Prediction-error method only) To stop the search and save the results after the current iteration has been completed, click Stop Iterations. To continue iterations from the current model, click the Continue iter button to assign current parameter values as initial guesses for the next search.
Estimating AR and ARMA Models Commands for Estimating Polynomial Time-Series Models (Continued) Method Name Description Supported Data armax Iterative prediction-error method to estimate linear, single-output ARMAX models. Time-domain, time-series iddata data object. arx Noniterative, least-squares method for estimating single-output and multiple-output linear AR models. Supports time- and frequency-domain time-series iddata data.
6 Time Series Model Identification Estimating State-Space Time-Series Models In this section... “Definition of State-Space Time-Series Model” on page 6-12 “Estimating State-Space Models at the Command Line” on page 6-12 Definition of State-Space Time-Series Model The discrete-time state-space model for a time series is given by the following equations: x(kT + T ) = Ax(kT ) + Ke(kT ) y(kT ) = Cx(kT ) + e(kT ) where T is the sampling interval and y(kT) is the output at time instant kT.
Estimating State-Space Time-Series Models Commands for Estimating State-Space Time-Series Models Command Description n4sid Noniterative subspace method for estimating discrete-time linear state-space models. Note When you use pem to estimate a state-space model, n4sid creates the initial model. pem Estimates linear, discrete-time time-series models using an iterative estimation method that minimizes the prediction error.
6 Time Series Model Identification Example – Identifying Time-Series Models at the Command Line The following example simulates a time-series model, compares spectral estimates, covariance estimates, and predicts output of the model: ts0 = idpoly([1 -1.5 0.
Estimating Nonlinear Models for Time-Series Data Estimating Nonlinear Models for Time-Series Data When a linear model provides an insufficient description of the dynamics, you can try estimating a nonlinear models. To learn more about when to estimate nonlinear models, see “When to Identify Linear Versus Nonlinear Models” in the Getting Started Guide. Before you can estimate models for time-series data, you must have already prepared the data as described in “Preparing Time-Series Data” on page 6-3.
6 6-16 Time Series Model Identification
7 Recursive Techniques for Model Identification • “What Is Recursive Estimation?” on page 7-2 • “Commands for Recursive Estimation” on page 7-3 • “Algorithms for Recursive Estimation” on page 7-6 • “Data Segmentation” on page 7-14
7 Recursive Techniques for Model Identification What Is Recursive Estimation? Many real-world applications, such as adaptive control, adaptive filtering, and adaptive prediction, require a model of the system to be available online while the system is in operation.
Commands for Recursive Estimation Commands for Recursive Estimation You can recursively estimate linear polynomial models, such as ARX, ARMAX, Box-Jenkins, and Output-Error models. If you are working with time-series data that contains no inputs and a single output, you can estimate AR (Auto-Regressive) and ARMA (Auto-Regressive Moving Average) single-output models.
7 Recursive Techniques for Model Identification adm and adg specify any of the four recursive algorithm, as described in “Algorithms for Recursive Estimation” on page 7-6. The following table summarizes the recursive estimation commands supported by the System Identification Toolbox product. The command description indicates whether you can estimate single-input, single-output, multiple-input, and multiple-output, and time-series (no input) models.
Commands for Recursive Estimation Commands for Linear Recursive Estimation (Continued) Command Description rpem Estimate parameters of multiple-input and single-output ARMAX/ARMA, Box-Jenkins, or Output-Error models using the general recursive prediction-error algorithm for estimating the parameter gradient. Note Unlike pem, rpem does not support state-space models.
7 Recursive Techniques for Model Identification Algorithms for Recursive Estimation In this section...
Algorithms for Recursive Estimation θ̂ ( t ) is the parameter estimate at time t. y(t) is the observed output at time t and ŷ ( t ) is the prediction of y(t) based on observations up to time t-1. The gain, K(t), determines how much the current prediction error y ( t ) − yˆ ( t ) affects the update of the parameter estimate. The estimation algorithms minimize the prediction-error term y ( t ) − yˆ ( t ) .
7 Recursive Techniques for Model Identification For models that do not have the linear regression form, it is not possible to compute exactly the predicted output and the gradient ψ ( t ) for the current parameter estimate θ̂ ( t − 1) . To learn how you can compute approximation for ψ ( t ) and θ̂ ( t − 1) for general model structures, see the section on recursive prediction-error methods in System Identification: Theory for the User by Lennart Ljung (Prentice Hall PTR, Upper Saddle River, NJ, 1999).
Algorithms for Recursive Estimation The Kalman filter is used to obtain Q(t).
7 Recursive Techniques for Model Identification To specify the Kalman filter algorithm, set adm to 'kf' and adg to the value of the drift matrix R1 (described in “Mathematics of the Kalman Filter Algorithm” on page 7-8).
Algorithms for Recursive Estimation horizon of this algorithm. Measurements older than τ = 1 1−λ typically carry a weight that is less than about 0.3. λ is called the forgetting factor and typically has a positive value between 0.97 and 0.995. Note In the linear regression case, the forgetting factor algorithm is known as the recursive least-squares (RLS) algorithm. The forgetting factor algorithm for λ = 1 is equivalent to the Kalman filter algorithm with R1=0 and R2=1.
7 Recursive Techniques for Model Identification Mathematics of the Unnormalized and Normalized Gradient Algorithm In the linear regression case, the gradient methods are also known as the least mean squares (LMS) methods.
Algorithms for Recursive Estimation To specify the unnormalized gain algorithm, set adm to 'ug' and adg to the value of the gain γ (described in “Mathematics of the Unnormalized and Normalized Gradient Algorithm” on page 7-12). To specify the normalized gain algorithm, set adm to 'ng' and adg to the value of the gain γ .
7 Recursive Techniques for Model Identification Data Segmentation For systems that exhibit abrupt changes while the data is being collected, you might want to develop models for separate data segments such that the system does not change during a particular data segment. Such modeling requires identification of the time instants when the changes occur in the system, breaking up the data into segments according to these time instants, and identification of models for the different data segments.
8 Model Analysis • “Overview of Model Validation and Plots” on page 8-2 • “Using Model Output Plots to Validate and Compare Models” on page 8-8 • “Using Residual Analysis Plots to Validate Models” on page 8-16 • “Using Impulse- and Step-Response Plots to Validate Models” on page 8-24 • “Using Frequency-Response Plots to Validate Models” on page 8-32 • “Creating Noise-Spectrum Plots” on page 8-40 • “Using Pole-Zero Plots to Validate Models” on page 8-47 • “Using Nonlinear ARX Plots to Validate Models” on pag
8 Model Analysis Overview of Model Validation and Plots In this section... “When to Validate Models” on page 8-2 “Ways to Validate Models” on page 8-2 “Data for Validating Models” on page 8-4 “Supported Model Plots” on page 8-4 “Plotting Models in the GUI” on page 8-5 “Getting Advice About Models” on page 8-7 When to Validate Models After estimating each model, you can validate whether the model reproduces system behavior within acceptable bounds.
Overview of Model Validation and Plots • Analyzing model response. For more information, see the following: - “Using Impulse- and Step-Response Plots to Validate Models” on page 8-24 - “Using Frequency-Response Plots to Validate Models” on page 8-32 For information about the response of the noise model, see “Creating Noise-Spectrum Plots” on page 8-40. • Plotting the poles and zeros of the linear parametric model. For more information, see “Using Pole-Zero Plots to Validate Models” on page 8-47.
8 Model Analysis Data for Validating Models For plots that compare model response to measured response, such as model output and residual analysis plots, you designate two types of data sets: one for estimating the models (estimation data), and the other for validating the models (validation data). Although you can designate the same data set to be used for estimating and validating the model, you risk overfitting your data.
Overview of Model Validation and Plots Plot Type Supported Models Learn More Frequency Response • All linear parametric models “Using Frequency-Response Plots to Validate Models” on page 8-32 • Spectral analysis (nonparametric) models Noise Spectrum • All linear parametric models • Spectral analysis (nonparametric) models “Creating Noise-Spectrum Plots” on page 8-40 Poles and Zeros All linear parametric models “Using Pole-Zero Plots to Validate Models” on page 8-47 Nonlinear ARX Nonlinear ARX
8 Model Analysis For example, in the following figure, Model output is selected. In this case, the models n4s4 is not included on the plot because only arx441 is active. Active model Inactive model Plots the model output of active models. Plots Include Only Active Models To close a plot, clear the corresponding check box in the System Identification Tool GUI. Tip To get information about a specific plot, select a help topic from the Help menu in the plot window.
Overview of Model Validation and Plots Getting Advice About Models Use the advice command on an estimated model to answer the following questions about the model: • Should I increase or decrease the model order? • Should I estimate a noise model? • Is feedback present? 8-7
8 Model Analysis Using Model Output Plots to Validate and Compare Models In this section...
Using Model Output Plots to Validate and Compare Models • For frequency-response data, the plot shows the simulated amplitude of the model frequency response. For linear models, you can estimate a model using time-domain data, and then validate the model using frequency domain data. For nonlinear models, you can only use time-domain data for both estimation and validation. The following figure shows a sample Model Output plot, created in the System Identification Tool GUI.
8 Model Analysis The main difference between simulation and prediction is whether the toolbox uses measured or computed previous outputs for computing the next output. Note Output-error models, obtained by fixing K to zero for state-space models and setting na=nc=nd=0 for polynomial models, do not use past outputs. Therefore, for these models, the simulated and the predicted outputs are the same for any value of k. Simulating a model means that you compute the response of a model to a particular input.
Using Model Output Plots to Validate and Compare Models s ≤ t , and all available outputs y(s), where s ≤ ( t − k ) . The argument s represents the data sample number. To make sure that the model picks up important dynamic properties, let the predicted time horizon kT be larger than the system time constants, where T is the sampling interval. Note Prediction with k=∞ means that no previous inputs are used in the computation and prediction matches simulation.
8 Model Analysis Because of the definition of Best Fit, it is possible for this value to be negative. A negative best fit is worse than 0% and can occur for the following reasons: • The estimation algorithm failed to converge. • The model was not estimated by minimizing y − yˆ . Best Fit can be negative when you minimized 1-step-ahead prediction during the estimation, but validate using the simulated output ŷ . • The validation data set was not preprocessed in the same way as the estimation data set.
Using Model Output Plots to Validate and Compare Models Model Output Plot Settings (Continued) Action Command Change between simulated output or predicted output. • Select Options > Simulated output or Options > k step ahead predicted output. Note Prediction is only available for time-domain validation data. • To change the prediction horizon, select Options > Set prediction horizon, and select the number of samples.
8 Model Analysis the estimated uncertainty in the model parameters to calculate confidence intervals and assumes the estimates have a Gaussian distribution. For example, for a 95% confidence interval, the region around the nominal curve represents the range of values that have a 95% probability of being the true system response. You can specify the confidence interval as a probability (between 0 and 1) or as the number of standard deviations of a Gaussian distribution. For example, a probability of 0.
Using Model Output Plots to Validate and Compare Models X0est=findstates(model,data) Next, specify the estimated initial states X0est as an argument in sim or predict. For example: y=sim(model,data,'InitialState',X0est) Command Description Example compare Plots simulated or predicted model output on top of the measured output. You should use an independent validation data set as input to the model.
8 Model Analysis Using Residual Analysis Plots to Validate Models In this section...
Using Residual Analysis Plots to Validate Models • For output-error (OE) models and when using instrumental-variable (IV) methods, make sure that your model shows independence of e and u, and pay less attention to the results of the whiteness of e. In this case, the modeling focus is on the dynamics G and not the disturbance properties H. • Correlation between residuals and input for negative lags, is not necessarily an indication of an inaccurate model.
8 Model Analysis For frequency-domain validation data, the plot shows the following two axes: • Estimated power spectrum of the residuals for each output • Transfer-function amplitude from the input to the residuals for each input-output pair For linear models, you can estimate a model using time-domain data, and then validate the model using frequency domain data. For nonlinear models, the System Identification Toolbox product supports only time-domain data.
Using Residual Analysis Plots to Validate Models Note If you are working in the System Identification Tool GUI, you can specify a custom confidence interval. If you are using the resid command, the confidence interface is fixed at 99%. The confidence interval corresponds to the range of residual values with a specific probability of being statistically insignificant for the system.
8 Model Analysis Residual Analysis Plot Settings Action Command Display confidence intervals around zero. • To display the dashed lines on either side of the nominal model curve, select Options > Show confidence intervals. Select this option again to hide the confidence intervals. Note Confidence internal are not available for nonlinear ARX and Hammerstein-Wiener models. Change the number of lags (data samples) for which to compute autocorellation and cross-correlation functions.
Using Residual Analysis Plots to Validate Models How to Plot Residuals at the Command Line The following table summarizes commands that generate residual-analysis plots for linear and nonlinear models. For detailed information about this command, see the corresponding reference page. Note Apply pe and resid to one model at a time. Command Description Example pe Computes and plots model prediction errors.
8 Model Analysis This opens an empty plot. 3 In the System Identification Tool window, click each model icon to display it on the Residual Analysis plot. Description of the Residual Plot Axes 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.
Using Residual Analysis Plots to Validate Models describe how the output is formed from 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(t-k) is not properly described by the model. The models arxqs and amx2222 extend beyond the confidence interval and do not perform as well as the other models.
8 Model Analysis Using Impulse- and Step-Response Plots to Validate Models In this section...
Using Impulse- and Step-Response Plots to Validate Models correlation analysis result on top of the transient responses of the parametric models. Because nonparametric and parametric models are derived using different algorithms, agreement between these models increases confidence in the parametric model results. What Does a Transient Response Plot Show? Transient response plots show the value of the impulse or step response on the vertical axis.
8 Model Analysis How to Plot Impulse and Step Response Using the GUI To create a transient analysis plot in the System Identification Tool GUI, select the Transient resp check box in the Model Views area. For general information about creating and working with plots, see “Working with Plots in the System Identification Tool GUI” on page 12-15. To include or exclude a model on the plot, click the corresponding model icon in the System Identification Tool GUI.
Using Impulse- and Step-Response Plots to Validate Models Transient Response Plot Settings (Continued) Action Command Display impulse response for linear model. Select Options > Impulse response. Note Not available for nonlinear models. Display the confidence interval. Note Only available for linear models. • To display the dashed lines on either side of the nominal model curve, select Options > Show confidence intervals. Select this option again to hide the confidence intervals.
8 Model Analysis Transient Response Plot Settings (Continued) Action Command Change time span over which the impulse or step response is calculated. For a scalar time span T, the resulting response is plotted from -T/4 to T. • Select Options > Time span (time units), and choose a new time span in units of time you specified for the model.
Using Impulse- and Step-Response Plots to Validate Models Transient Response Plot Settings (Continued) Action Command (Multiple-output system only) Select an input-output pair to view the noise spectrum corresponding to those channels. Select the output by name in the Channel menu. (Step response for nonlinear models only) Set level of the input step. If the plotted models include a noise model, you can display the transient response properties associated with each output channel.
8 Model Analysis true system response. You can specify the confidence interval as a probability (between 0 and 1) or as the number of standard deviations of a Gaussian distribution. For example, a probability of 0.99 (99%) corresponds to 2.58 standard deviations. Note The calculation of the confidence interval assumes that the model sufficiently describes the system dynamics and the model residuals pass independence tests.
Using Impulse- and Step-Response Plots to Validate Models The following table summarizes commands that generate impulse- and step-response plots. For detailed information about each command, see the corresponding reference page. Command Description Example impulse Plots impulse response for idpoly, idproc, idarx, idss, and idgrey model objects. Estimates and plots impulse response models for iddata objects.
8 Model Analysis Using Frequency-Response Plots to Validate Models In this section... “What Is Frequency Response?” on page 8-32 “How Frequency Response Helps to Validate Models” on page 8-33 “What Does a Frequency-Response Plot Show?” on page 8-34 “How to Plot Bode Plots Using the GUI” on page 8-35 “How to Plot Bode and Nyquist Plots at the Command Line” on page 8-38 What Is Frequency Response? Frequency response plots show the complex values of a transfer function as a function of frequency.
Using Frequency-Response Plots to Validate Models is scaled by the sampling interval T to make the frequency function periodic with the sampling frequency 2π T . How Frequency Response Helps to Validate Models You can plot the frequency response of a model to gain insight into the characteristics of linear model dynamics, including the frequency of the peak response and stability margins. Frequency-response plots are available for all linear parametric models and spectral analysis (nonparametric) models.
8 Model Analysis What Does a Frequency-Response Plot Show? System Identification Tool GUI supports the following types of frequency-response plots for linear parametric models, linear state-space models, and nonparametric frequency-response models: • Bode plot of the model response. A Bode plot consists of two plots. The top plot shows the magnitude G by which the transfer function G magnifies the amplitude of the sinusoidal input.
Using Frequency-Response Plots to Validate Models How to Plot Bode Plots Using the GUI To create a frequency-response plot for parametric linear models in the System Identification Tool GUI, select the Frequency resp check box in the Model Views area. For general information about creating and working with plots, see “Working with Plots in the System Identification Tool GUI” on page 12-15. To include or exclude a model on the plot, click the corresponding model icon in the System Identification Tool GUI.
8 Model Analysis true system response. You can specify the confidence interval as a probability (between 0 and 1) or as the number of standard deviations of a Gaussian distribution. For example, a probability of 0.99 (99%) corresponds to 2.58 standard deviations. The following table summarizes the Frequency Function plot settings. Frequency Function Plot Settings Action Command Display the confidence interval.
Using Frequency-Response Plots to Validate Models Frequency Function Plot Settings (Continued) Action Command Change the frequency values for computing the noise spectrum. Select Options > Frequency range and specify a new frequency vector in units of rad/s. The default frequency vector is 128 linearly distributed values, greater than zero and less than or equal to the Nyquist frequency.
8 Model Analysis Frequency Function Plot Settings (Continued) Action Command Change amplitude scale between linear and logarithmic. Select Style > Linear amplitude scale or Style > Log amplitude scale. (Multiple-output system only) Select an input-output pair to view the noise spectrum corresponding to those channels. Select the output by name in the Channel menu. Note You cannot view cross spectra between different outputs.
Using Frequency-Response Plots to Validate Models where sd is the number of standard deviations of a Gaussian distribution. For example, a confidence value of 99% for the nominal model curve corresponds to 2.58 standard deviations. To display a filled confidence region, use the following syntax: command(model,'sd',sd,'fill') The following table summarizes commands that generate Bode and Nyquist plots for linear models.
8 Model Analysis Creating Noise-Spectrum Plots In this section... “Supported Models” on page 8-40 “What Does a Noise Spectrum Plot Show?” on page 8-40 “Displaying the Confidence Interval” on page 8-41 “How to Plot the Noise Spectrum Using the GUI” on page 8-42 “How to Plot the Noise Spectrum at the Command Line” on page 8-45 Supported Models When you estimate the noise model of your linear system, you can plot the spectrum of the estimated noise model.
Creating Noise-Spectrum Plots Whereas the frequency-response plot shows the response of G, the noise-spectrum plot shows the frequency-response of the noise model H. For input-output models, the noise spectrum is given by the following equation: ( ) Φ v (ω) = λ H eiω 2 For time-series models (no input), the vertical axis of the noise-spectrum plot is the same as the dynamic model spectrum. These axes are the same because there is no input for time series and y = He .
8 Model Analysis Gaussian distribution. For example, a probability of 0.99 (99%) corresponds to 2.58 standard deviations. Note The calculation of the confidence interval assumes that the model sufficiently describes the system dynamics and the model residuals pass independence tests. How to Plot the Noise Spectrum Using the GUI To create a noise spectrum plot for parametric linear models in the GUI, select the Noise spectrum check box in the Model Views area.
Creating Noise-Spectrum Plots The following table summarizes the Noise Spectrum plot settings. Noise Spectrum Plot Settings Action Command Display the confidence interval. • To display the dashed lines on either side of the nominal model curve, select Options > Show confidence intervals. Select this option again to hide the confidence intervals. • To change the confidence value, select Options > Set % confidence level, and choose a value from the list.
8 Model Analysis Noise Spectrum Plot Settings (Continued) Action Command Change the frequency values for computing the noise spectrum. Select Options > Frequency range and specify a new frequency vector in units of radians per second. The default frequency vector is 128 linearly distributed values, greater than zero and less than or equal to the Nyquist frequency. Enter the frequency vector using any one of following methods: • MATLAB expression, such as [1:100]*pi/100 or logspace(-3,-1,200).
Creating Noise-Spectrum Plots Noise Spectrum Plot Settings (Continued) Action Command Change amplitude scale between linear and logarithmic. Select Style > Linear amplitude scale or Style > Log amplitude scale. (Multiple-output system only) Select an input-output pair to view the noise spectrum corresponding to those channels. Select the output by name in the Channel menu. Note You cannot view cross spectra between different outputs.
8 Model Analysis frequency response of v(t). To compute v(t), which represents the actual noise term in the system, use the following commands: ysimulated = sim(m,data); v = ymeasured-ysimulated; ymeasured is data.y. v is the noise term v(t), as described in “What Does a Noise Spectrum Plot Show?” on page 8-40 and corresponds to the difference between the simulated response ysimulated and the actual response ymeasured.
Using Pole-Zero Plots to Validate Models Using Pole-Zero Plots to Validate Models In this section... “Supported Models” on page 8-47 “What Does a Pole-Zero Plot Show?” on page 8-47 “How to Plot Model Poles and Zeros Using the GUI” on page 8-48 “How to Plot Poles and Zeros at the Command Line” on page 8-50 “Reducing Model Order Using Pole-Zero Plots” on page 8-51 Supported Models You can create pole-zero plots of linear input-output polynomial, state-space, and grey-box models.
8 Model Analysis most-delayed and least-delayed input. For example, there two poles and one zero in the following ARX model: y(t) − 1.5 y(t − T ) + 0.7 y(t − 2T ) = 0.9u(t) + 0.5u(t − T ) The following figure shows a sample pole-zero plot of the model with confidence intervals. x indicate poles and o indicate zeros.
Using Pole-Zero Plots to Validate Models In addition, you can display a confidence interval for each pole and zero on the plot. The confidence interval corresponds to the range of pole or zero values with a specific probability of being the actual pole or zero of the system. The toolbox uses the estimated uncertainty in the model parameters to calculate confidence intervals and assumes the estimates have a Gaussian distribution.
8 Model Analysis Zeros and Poles Plot Settings (Continued) Action Command Show the unit circle. Select Style > Unit circle. Select this option again to hide the unit circle. (Multiple-output system only) Select an input-output pair to view the poles and zeros corresponding to those channels. Select the output by name in the Channel menu.
Using Pole-Zero Plots to Validate Models Reducing Model Order Using Pole-Zero Plots You can use pole-zero plots to evaluate whether it might be useful to reduce model order. When confidence intervals for a pole-zero pair overlap, this overlap indicates a possible pole-zero cancelation. For example, you can use the following syntax to plot a 1-standard-deviation confidence interval around model poles and zeros. pzmap(model,'sd',1) If poles and zeros overlap, try estimating a lower order model.
8 Model Analysis Using Nonlinear ARX Plots to Validate Models In this section... “About Nonlinear ARX Plots” on page 8-52 “How to Plot Nonlinear ARX Plots Using the GUI” on page 8-52 “Configuring the Nonlinear ARX Plot” on page 8-53 “Axis Limits, Legend, and 3-D Rotation” on page 8-54 “How to Plot Nonlinear ARX Plots at the Command Line” on page 8-55 About Nonlinear ARX Plots The Nonlinear ARX plot displays the characteristics of model nonlinearities as a function of one or two regressors.
Using Nonlinear ARX Plots to Validate Models The following figure shows a sample nonlinear ARX plot. Configuring the Nonlinear ARX Plot To include or exclude a model on the plot, click the corresponding model icon in the System Identification Tool GUI. Active models display a thick line inside the Model Board icon. To configure the plot: 1 If your model contains multiple output, select the output channel in the Select nonlinearity at output list.
8 Model Analysis 3 Select Regressor 1 from the list of available regressors. In the Range field, enter the range of values to include on the plot for this regressor. The regressor values are plotted on the Reg1 axis. 4 Specify a second regressor for a 3-D plot by selecting one of the following types of options: • Select Regressor 2 to display three axes. In the Range field, enter the range of values to include on the plot for this regressor. The regressor values are plotted on the Reg2 axis.
Using Nonlinear ARX Plots to Validate Models Changing Appearance of the Nonlinear ARX Plot (Continued) Action Command Hide or show the legend. Select Style > Legend. Select this option again to show the legend. (Three axes only) Rotate in three dimensions. Select Style > 3D Rotate and drag the axes on the plot to a new orientation. To disable three-dimensional rotation, select Style > 3D Rotate again. Note Available only when you have selected two regressors as independent variables.
8 Model Analysis Using Hammerstein-Wiener Plots to Validate Models In this section...
Using Hammerstein-Wiener Plots to Validate Models Note The Hamm-Wiener check box is unavailable if you do not have a Hammerstein-Wiener model in the Model Board. To include or exclude a model on the plot, click the corresponding model icon in the System Identification Tool GUI. Active models display a thick line inside the model icon, as shown in the following figure. Selected block is highlighted. Supported plots for linear block Hide or show the top pane.
8 Model Analysis How to Plot Hammerstein-Wiener Plots at the Command Line You can plot input and output nonlinearity and linear responses for Hammerstein-Wiener models using the following syntax: plot(model) model must be an idnlhw model object. You can use additional plot arguments to specify the following information: • Include several Hammerstein-Wiener models on the plot. • Configure how to evaluate the nonlinearity at each input and output channel.
Using Hammerstein-Wiener Plots to Validate Models • To plot uNL as a command of the input data, click the uNL block. • To plot yNL as a command of its inputs, click the yNL block. The selected block is highlighted in green. Note An input to the output nonlinearity block yNL is the output from the Linear Block and not the measured input data. 3 If your model contains multiple variables, select the channel in the Select nonlinearity at channel list.
8 Model Analysis • Bode • Pole-Zero Map 5 If you selected to plot step or impulse response, you can set the time span. Select Options > Time span and enter a new time span in units of time you specified for the model. For a time span T, the resulting response is plotted from -T/4 to T. The default time span is 10. Click Apply and then Close. 6 If you selected to plot a Bode plot, you can set the frequency range.
Using Akaike’s Criteria to Validate Models Using Akaike’s Criteria to Validate Models In this section... “Definition of FPE” on page 8-61 “Computing FPE” on page 8-62 “Definition of AIC” on page 8-62 “Computing AIC” on page 8-63 Definition of FPE Akaike’s Final Prediction Error (FPE) criterion provides a measure of model quality by simulating the situation where the model is tested on a different data set. After computing several different models, you can compare them using this criterion.
8 Model Analysis ⎛ N 1 V = det ⎜ N ε t, θ N ⎜ ∑ ⎝ 1 ( ) ( ε ( t, θ N )) T ⎞ ⎟ ⎟ ⎠ where θ N represents the estimated parameters. Computing FPE You can compute Akaike’s Final Prediction Error (FPE) criterion for linear and nonlinear models. Note FPE for nonlinear ARX models that include a tree partition nonlinearity is not supported. To compute FPE, use the fpe command, as follows: FPE = fpe(m1,m2,m3,...,mN) According to Akaike’s theory, the most accurate model has the smallest FPE.
Using Akaike’s Criteria to Validate Models Akaike’s Information Criterion (AIC) is defined by the following equation: AIC = log V + 2d N where V is the loss function, d is the number of estimated parameters, and N is the number of values in the estimation data set. The loss function V is defined by the following equation: ⎛ N 1 V = det ⎜ N ε t, θ N ⎜ ∑ 1 ⎝ ( ) ( ε ( t, θ N )) T ⎞ ⎟ ⎟ ⎠ where θ N represents the estimated parameters.
8 Model Analysis Computing Model Uncertainty In this section... “Why Analyze Model Uncertainty?” on page 8-64 “What Is Model Covariance?” on page 8-64 “Viewing Model Uncertainty Information” on page 8-65 Why Analyze Model Uncertainty? In addition to estimating model parameters, the toolbox algorithms also estimate variability of the model parameters that result from random disturbances in the output.
Computing Model Uncertainty Computing the covariance matrix is based on the assumption that the model structure gives the correct description of the system dynamics. For models that include a disturbance model H, a correct uncertainty estimate assumes that the model produces white residuals. To determine whether you can trust the estimated model uncertainty values, perform residual analysis tests on your model, as described in “Using Residual Analysis Plots to Validate Models” on page 8-16.
8 Model Analysis Type model.dA at the prompt to access the estimated standard deviations of the model.A estimated property, where model represents the name of the model object, and A represents any estimated model property. In general, you prefix the name of the estimated property with a d to get the standard deviation estimate for that property. For example, to get the standard deviation value of the A polynomial in an estimated ARX model, type model.da.
Troubleshooting Models Troubleshooting Models In this section... “About Troubleshooting Models” on page 8-67 “Model Order Is Too High or Too Low” on page 8-67 “Nonlinearity Estimator Produces a Poor Fit” on page 8-68 “Substantial Noise in the System” on page 8-69 “Unstable Models” on page 8-69 “Missing Input Variables” on page 8-70 “Complicated Nonlinearities” on page 8-71 About Troubleshooting Models During validation, you might find that your model output fits the validation data poorly.
8 Model Analysis When a low-order model fits the validation data poorly, try estimating a higher-order model to see if the fit improves. For example, if a Model Output plot shows that a fourth-order model gives poor results, try estimating an eighth-order model. When a higher-order model improves the fit, you can conclude that higher-order models might be required and linear models might be sufficient. You should use an independent data set to validate your models.
Troubleshooting Models Substantial Noise in the System There are a couple of indications that you might have substantial noise in your system and might need to use linear model structures that are better equipped to model noise.
8 Model Analysis model for control design. In this case, you can import your unstable model into Simulink or Control System Toolbox products. One way to check if a nonlinear model is unstable is to plot the simulated model output on top of the validation data. If the simulated output diverges from measured output, the model is unstable. However, agreement between model output and measured output does not guarantee stability.
Troubleshooting Models Inputs need not be control signals. Any measurable signal can be considered an input, including measurable disturbances. Complicated Nonlinearities If the Model Output plot and Residual Analysis plot shows a poor fit, consider if nonlinear effects are present in the system. You can model the nonlinearities by performing a simple transformation on the signals to make the problem linear in the new variables.
8 Model Analysis Next Steps After Getting an Accurate Model After you get an accurate model, you can simulate or predict model output. For more information, see Chapter 9, “Simulation and Prediction”. For linear parametric models (idmodel objects), you can perform the following operations: • Transform between continuous-time and discrete-time representation. See “Transforming Between Discrete-Time and Continuous-Time Representations” on page 3-112.
Next Steps After Getting an Accurate Model Tip To export a model from the GUI, drag the model icon to the To Workspace rectangle. For more information about working with the GUI, see Chapter 12, “Using the System Identification Tool GUI”. If you have the Control System Toolbox software installed, you can import your linear plant model for control-system design. For more information, see “Using Models with Control System Toolbox Software” on page 10-2.
8 8-74 Model Analysis
9 Simulation and Prediction • “Simulating Versus Predicting Output” on page 9-2 • “Simulation and Prediction in the GUI” on page 9-4 • “Example – Simulating Model Output with Noise at the Command Line” on page 9-5 • “Example – Simulating a Continuous-Time State-Space Model at the Command Line” on page 9-6 • “Predicting Model Output at the Command Line” on page 9-7 • “Specifying Initial States” on page 9-8
9 Simulation and Prediction Simulating Versus Predicting Output Simulating a model means that you compute the response of a model to a particular input. Then, the toolbox feeds this computed output into the differential (continuous-time) or difference (discrete-time) equation for calculating the next output value.
Simulating Versus Predicting Output Note Prediction with k=∞ means that no previous inputs are used in the computation and prediction matches simulation.
9 Simulation and Prediction Simulation and Prediction in the GUI To learn how to display simulated or predicted output using the System Identification Tool GUI, see the description of the plot settings in “How to Plot Model Output Using the GUI” on page 8-11. For information about simulating identified models in the Simulink environment, see “Simulating Model Output” on page 11-6.
Example – Simulating Model Output with Noise at the Command Line Example – Simulating Model Output with Noise at the Command Line This example demonstrates how you can create input data and a model, and then use the data and the model to simulate output data. In this case, you use the following ARMAX model with Gaussian noise e: y(t) − 1.5 y(t − 1) + 0.7 y(t − 2) = u(t − 1) + 0.5u(t − 2) + e(t) − e(t − 1) + 0.
9 Simulation and Prediction Example – Simulating a Continuous-Time State-Space Model at the Command Line This example demonstrates how to simulate a continuous-time state-space model using a random binary input u and a sampling interval of 0.1 s. Consider the following state-space model: ⎡ −1 1 ⎤ ⎡ 1 ⎤ ⎡ 0 .5 ⎤ x = ⎢ ⎥ x + ⎢ 0 .5 ⎥ u + ⎢ 0 .5 ⎥ e − 0 . 5 0 ⎣ ⎦ ⎣ ⎦ ⎣ ⎦ y = [1 0] x + e where e is Gaussian white noise with variance 7.
Predicting Model Output at the Command Line Predicting Model Output at the Command Line Use the following syntax to compute k-step-ahead prediction of the output signal using model m: yhat = predict(m,[y u],k) The predicted value yˆ ( t | t − k ) is computed using information in u(s) up to time s=t, and then information in y(s) up to time s=t-kT, where T is the sampling interval. The way information in past outputs is used depends on the disturbance model of m.
9 Simulation and Prediction Specifying Initial States In this section... “When to Specify Initial States” on page 9-8 “Setting Initial States to Zero” on page 9-8 “Setting Initial States to Equilibrium Values” on page 9-9 “Estimating Initial States from the Data” on page 9-9 When to Specify Initial States The sim and predict commands require initial states to start the computations.
Specifying Initial States You can use the following shortcut syntax for setting initial states to zero: y=sim(model,data,'InitialState','z') y=predict(model,data,'InitialState','z') Setting Initial States to Equilibrium Values If you have physical insight about the starting point of the system, create a vector of specific initial states at the command line.
9 Simulation and Prediction When you simulate a multiexperiment model, use the pe command to estimate initial states for the data from that specific experiment. For example, suppose you estimate a three-state model M using a merged data set Z, which contains data from five experiments—z1, z2, z3, z4, and z5: Z = merge(z1,z2,z3,z4,z5); M = n4sid(Z,3); If you want to simulate using data from z2, you must estimate the initial states for the second experiment Z(z2.
10 Using Identified Models in Control Design
10 Using Identified Models in Control Design Using Models with Control System Toolbox Software In this section...
Using Models with Control System Toolbox™ Software Using balred to Reduce Model Order In some cases, the order of your identified model might be higher than necessary to capture the dynamics. If you have the Control System Toolbox software, you can use balred to compute a state-spate model approximation with a reduced model order for any idmodel object, including idarx, idpoly, idss, and idgrey. For more information about using balred, see the corresponding reference page.
10 Using Identified Models in Control Design Note The syntax sisotool(model('m')) is equivalent to sisotool(model('measured')). For more information about controller design using SISO Design Tool and Control System Toolbox commands, see the Control System Toolbox documentation. Converting Models to LTI Objects Control System Toolbox commands operate on LTI objects. To design a controller for a plant model, you must first convert the System Identification Toolbox model object to an LTI object.
Using Models with Control System Toolbox™ Software model = model('measured') % Convert to LTI object LTI_sys = idss(model) The LTI object includes only the dynamic model and not the noise model, which is estimated for every linear model in the System Identification Toolbox software. Note To include noise channels in the LTI models, first use noisecnv to convert the noise in the idmodel object to measured channels, and then convert to an LTI object.
10 Using Identified Models in Control Design Displaying Identified Models in the LTI Viewer When the MATLAB software is installed, the System Identification Tool GUI contains the To LTI Viewer rectangle. To plot models in the LTI Viewer, drag and drop the corresponding icon to the To LTI Viewer rectangle in the System Identification Tool GUI.
Using Models with Control System Toolbox™ Software u = iddata([], idinput([800 2],'rbs')); % Simulate model output using System Identification Toolbox % with added noise y = sim(m0,u,'noise') % Form an input-output iddata object Data = [y u]; % Estimate state-space model from the generated data % using System Identification Toolbox command pem m = pem(Data(1:400)) % Convert the model to a Control System Toolbox transfer function tf(m) % Plot model output for model m using System Identification Toolbox comp
10 10-8 Using Identified Models in Control Design
11 Using System Identification Toolbox Blocks • “System Identification Toolbox Block Library” on page 11-2 • “Opening the System Identification Toolbox Block Library” on page 11-3 • “Preparing Data” on page 11-4 • “Identifying Linear Models” on page 11-5 • “Simulating Model Output” on page 11-6 • “Example – Simulating a Model Using Simulink Software” on page 11-9
11 Using System Identification Toolbox™ Blocks System Identification Toolbox Block Library System Identification Toolbox provides blocks for sharing information between the MATLAB and Simulink environments. You can use the System Identification Toolbox block library to perform the following tasks: • Stream time-domain data source (iddata object) into a Simulink model. • Export data from a simulation in Simulink software as a System Identification Toolbox data object (iddata object).
Opening the System Identification Toolbox™ Block Library Opening the System Identification Toolbox Block Library To open the System Identification Toolbox block library, select Start > Simulink > Library Browser. In the Library Browser, select System Identification Toolbox.
11 Using System Identification Toolbox™ Blocks Preparing Data The following table summarizes the blocks you use to transfer data between the MATLAB and Simulink environments. After you add a block to the Simulink model, double-click the block to specify block parameters. For an example of bringing data into a Simulink model, see the tutorial on estimating process models in the System Identification Toolbox Getting Started Guide.
Identifying Linear Models Identifying Linear Models The following table summarizes the blocks you use to estimate model parameters in a Simulink model during simulation and export the results to the MATLAB environment. After you add a block to the model, double-click the block to specify block parameters. Block Description AR Estimator Estimate AR model parameters from time-series data, which has one output and no input. ARMAX Estimator Estimate ARMAX model parameters from input/output data.
11 Using System Identification Toolbox™ Blocks Simulating Model Output In this section... “When to Use Simulation Blocks” on page 11-6 “Summary of Simulation Blocks” on page 11-6 “Specifying Initial Conditions for Simulation” on page 11-7 When to Use Simulation Blocks Add model simulation blocks to your Simulink model from the System Identification Toolbox block library when you want to: • Represent the dynamics of a physical component in a Simulink model using a data-based nonlinear model.
Simulating Model Output Block Description IDNLHW Model Simulate idnlhw model in Simulink. IDNLGREY Model Simulate nonlinear ODE (idnlgrey model object) in Simulink. After importing the model into Simulink, use the block parameter dialog box to specify the initial conditions for simulating that block, as described in “Specifying Initial Conditions for Simulation” on page 11-7. For information about configuring each block, see the corresponding reference pages.
11 Using System Identification Toolbox™ Blocks m2=idss(m1); For more information about specifying initial conditions for simulation, see the IDMODEL Model reference page. Specifying Initial States of Nonlinear ARX Models The states of a nonlinear ARX model correspond to the dynamic elements of the nonlinear ARX model structure, which are the model regressors.
Example – Simulating a Model Using Simulink® Software Example – Simulating a Model Using Simulink Software In this example, you set the initial states for simulating a model such that the simulation provides a best fit to measured input-output data.
11 11-10 Using System Identification Toolbox™ Blocks
12 Using the System Identification Tool GUI • “Steps for Using the System Identification Tool GUI” on page 12-2 • “Starting and Managing GUI Sessions” on page 12-3 • “Managing Models in the GUI” on page 12-9 • “Working with Plots in the System Identification Tool GUI” on page 12-15 • “Customizing the System Identification Tool GUI” on page 12-21
12 Using the System Identification Tool GUI Steps for Using the System Identification Tool GUI A typical workflow in the System Identification Tool GUI includes the following steps: 1 Import your data into the MATLAB workspace, as described in “Importing Data into the MATLAB Workspace” on page 1-5. 2 Start a new session in the System Identification Tool GUI, or open a saved session. For more information, see “Starting a New Session in the GUI” on page 12-4.
Starting and Managing GUI Sessions Starting and Managing GUI Sessions In this section...
12 Using the System Identification Tool GUI Starting a New Session in the GUI To start a new session in the System Identification Tool GUI, type the following command in the MATLAB Command Window: ident Alternatively, you can start a new session by selecting Start > Toolboxes > System Identification > System Identification Tool GUI in the MATLAB desktop. This action opens the System Identification Tool GUI. Note Only one session can be open at a time.
Starting and Managing GUI Sessions Description of the System Identification Tool Window The following figure describes the different areas in the System Identification Tool GUI. Data Board Select check boxes to display data plots. Model Board Select check boxes to display model plots. The layout of the window organizes tasks and information from left to right.
12 Using the System Identification Tool GUI the Import data menu and end in the bottom-right corner by plotting the characteristics of your estimated model on model plots. For more information about using the System Identification Tool GUI, see “Steps for Using the System Identification Tool GUI” on page 12-2. The Data Board area, located below the Import data menu in the System Identification Tool GUI, contains rectangular icons that represent the data you imported into the GUI.
Starting and Managing GUI Sessions Task Command Comment Close the current session and start a new session. File > Close session You are prompted to save the current session before closing it. Merge the current session with a previously saved session. File > Merge session You must start a new session and import data or models before you can select to merge it with a previously saved session. You are prompted to select the session file to merge with the current.
12 Using the System Identification Tool GUI Exiting the System Identification Tool GUI To exit the System Identification Tool GUI, click Exit in the bottom-left corner of the window. Tip Alternatively, select File > Exit System Identification Tool GUI.
Managing Models in the GUI Managing Models in the GUI In this section...
12 Using the System Identification Tool GUI Viewing Model Properties You can get information about each model in the System Identification Tool GUI by right-clicking the corresponding model icon. The Data/model Info dialog box opens. This dialog box describes the contents and the properties of the corresponding model. It also displays any associated notes and the command-line equivalent of the operations you used to create this model.
Managing Models in the GUI Renaming Models and Changing Display Color You can rename a model and change its display color by double-clicking the model icon in the System Identification Tool GUI. The Data/model Info dialog box opens. This dialog box describes both the contents and the properties of the model. The object description area displays the syntax of the operations you used to create the model in the GUI. To rename the model, enter a new name in the Model name field.
12 Using the System Identification Tool GUI When you need additional space for organizing model icons, select Options > Extra model/data board in the System Identification Tool GUI. This action opens an extra session window with blank rectangles. The new window is an extension of the current session and does not represent a new session. Tip When you import or estimate models and there is insufficient space for the icons, an additional session window opens automatically.
Managing Models in the GUI To restore a model from Trash, drag its icon from Trash to the Model Board in the System Identification Tool GUI. You can view the Trash contents by double-clicking the Trash icon. Note You must restore a model to the Model Board; you cannot drag model icons to the Data Board. To permanently delete all items in Trash, select Options > Empty trash. Exiting a session empties Trash automatically.
12 Using the System Identification Tool GUI When you export models to the MATLAB workspace, the resulting variables have the same name as in the System Identification Tool GUI.
Working with Plots in the System Identification Tool GUI Working with Plots in the System Identification Tool GUI In this section...
12 Using the System Identification Tool GUI Data Tip on a Plot Changing and Restoring Default Axis Limits There are two ways to change which portion of the plot is currently in view: • “Magnifying Plots” on page 12-16 • “Setting Axis Limits” on page 12-17 Magnifying Plots Enable zoom by selecting Style > Zoom in the plot window. To disable zoom, select Style > Zoom again. Tip To verify that zoom is active, click the Style menu. A check mark should appear next to Zoom.
Working with Plots in the System Identification Tool GUI • To zoom in default increments, left-click the portion of the plot you want to center in the plot window. • To zoom in on a specific region, click and drag a rectangle that identifies the region for magnification. When you release the mouse button, the selected region is displayed. • To zoom out, right-click on the plot. Note To restore the full range of the data in view, select Options > Autorange in the plot window.
12 Using the System Identification Tool GUI Note To view the entire data range, select Options > Autorange in the plot window. Selecting Measured and Noise Channels in Plots Model inputs and outputs are called channels. When you create a plot of a multivariable input-output data set or model, the plot only shows one input-output channel pair at a time. The selected channel names are displayed in the title bar of the plot window.
Working with Plots in the System Identification Tool GUI Grid, Line Styles, and Redrawing Plots There are several Style options that are common to all plot types. These include the following: • “Grid Lines” on page 12-19 • “Solid or Dashed Lines” on page 12-19 • “Plot Redrawing” on page 12-19 Grid Lines To toggle showing or hiding grid lines, select Style > Grid.
12 Using the System Identification Tool GUI System Identification Tool GUI, and then open it in a MATLAB Figure window to fine-tune the display. After you create the plot, as described in “Plotting Models in the GUI” on page 8-5, select File > Copy figure in the plot window. This command opens the plot in a MATLAB Figure window. Printing Plots To print a System Identification Toolbox plot, select File > Print in the plot window. In the Print dialog box, select the printing options and click OK.
Customizing the System Identification Tool GUI Customizing the System Identification Tool GUI In this section... “Types of GUI Customization” on page 12-21 “Displaying Warnings While You Work” on page 12-21 “Saving Session Preferences” on page 12-21 “Modifying idlayout.m” on page 12-22 Types of GUI Customization The System Identification Tool GUI lets you customize the window behavior and appearance.
12 Using the System Identification Tool GUI • Four recently used sessions • Plot options, such as line styles, zoom, grid, and whether the input is plotted using zero-order hold or first-order hold between samples You can only edit idprefs.mat by changing preferences in the GUI. The idprefs.mat file is located in the same directory as startup.m, by default. To change the location where your preferences are saved, use the midprefs command with the new path as the argument.
Customizing the System Identification Tool GUI Note When you save preferences using Options > Save preferences to idprefs.mat, these preferences override the defaults in idlayout.m. To give idlayout.m precedence every time you start a new session, select Options > Default preferences.
12 12-24 Using the System Identification Tool GUI
Index A Index active model in GUI 8-5 advice for data 1-84 for models 8-7 AIC 8-61 definition 8-62 Akaike’s Final Prediction Error (FPE) 8-61 Akaike’s Information Criterion (AIC) 8-61 Algorithm property 2-15 algorithms for estimation recursive 7-6 spectral models 3-5 aliasing effects 1-103 AR 6-7 ARMA 6-7 ARMAX 3-44 ARX 3-44 ARX Model Structure Selection window 3-55 B best fit definition 8-11 negative value 8-12 BJ model.
Index data creating iddata object 1-47 creating idfrd object 1-67 creating subsets 1-31 detrending 1-94 exporting to MATLAB workspace 1-45 filter 1-107 frequency-domain 1-8 frequency-response 1-10 importing into System Identification Tool GUI 1-13 managing in GUI 1-13 merging 1-33 missing data 1-90 multiexperiment data 1-33 outliers 1-91 plotting 1-75 renaming in GUI 1-41 resampling 1-100 sampling interval 1-28 segmentation 7-14 selecting 1-86 simulating 1-115 supported types 1-5 time-domain 1-6 time-serie
Index H Hammerstein-Wiener models 4-15 Hammerstein-Wiener plot 8-56 impulse-response plot 8-24 independence test 8-16 initial states for simulation and prediction 9-8 I K idarx 2-13 iddata K matrix 3-89 Kalman filter algorithm 7-8 concatenating 1-65 creating 1-47 subreferencing 1-55 ident 12-4 L idfrd concatenating 1-71 creating 1-67 model 2-13 subreferencing 1-70 idgrey 2-13 idlayout.
Index model black-box polynomial 3-41 estimating frequency response 3-2 estimating process model 3-22 estimating transient response 3-14 exporting to MATLAB workspace 12-13 grey-box estimation 5-1 Hammerstein-Wiener estimation 4-15 importing into GUI 12-9 linear grey-box estimation 5-6 managing in GUI 12-9 nonlinear ARX estimation 4-4 nonlinear black-box estimation 4-1 nonlinear grey-box estimation 5-16 ordinary difference equation 5-1 ordinary differential equation 5-1 plotting 8-4 predict output 9-7 prop
Index normalized gradient algorithm 7-11 O OE model. See Output-Error model offset levels 1-94 order.
Index session definition 12-3 managing in GUI 12-3 preferences 12-21 starting 12-4 sigmoid network 4-25 simulating data 1-115 simulating model output 9-1 initial states 9-8 Simulink 11-2 slident 11-3 spa algorithm 3-5 spafdr algorithm 3-5 spectral analysis 3-2 algorithm 3-5 frequency resolution 3-6 spectrum normalization 3-11 spectrum normalization 3-11 state-space models 3-73 canonical parameterization 3-91 estimating order 3-79 for time series 6-12 free parameterization 3-84 structured parameterization
Index U W uncertainty of models 8-64 confidence interval on plots 8-65 covariance 8-64 unnormalized gradient algorithm 7-11 unstable models 8-69 warnings 12-21 wavelet network 4-25 whiteness test 8-16 Working Data 1-29 V validating models 8-2 comparing model output 8-8 residual analysis 8-16 troubleshooting 8-67 Validation Data 1-29 X X0 matrix 3-89 Y Yule-Walker approach 6-11 Index-7