| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → System Identification Toolbox |
| Contents | Index |
| Learn more about System Identification Toolbox |
| On this page… |
|---|
Loading Data into the MATLAB Workspace Plotting the Input/Output Data Removing Equilibrium Values from the Data Using Objects to Represent Data for System Identification |
Load the data in co2data.mat by typing the following in the MATLAB Command Window:
load co2data;
This command loads the following five variables into the MATLAB Workspace:
Input_exp1 and Output_exp1 are the input and output data from the first experiment, respectively.
Input_exp2 and Output_exp2 are the input and output data from the second experiment, respectively.
Time is the time vector from 0 to 1000 minutes, increasing in equal increments of 0.5 min.
For both experiments, the input data consists of two columns of values. The first column of values is the rate of chemical consumption (in kilograms per minute), and the second column of values is the current (in amperes). The output data is a single column of the rate of carbon-dioxide production (in milligrams per minute).
You can plot the input and output data from both experiments using the following commands:
% Plot the input and output data from both experiments
plot(Time,Input_exp1,Time,Output_exp1)
legend('Input 1','Input 2','Output 1')
figure
plot(Time,Input_exp2,Time,Output_exp2)
legend('Input 1','Input 2','Output 1')The resulting plot shows the first experiment, where the operator applies a pulse wave to each input to perturb it from its steady-state equilibrium.
Input and Output Data from Experiment 1

The next plot shows the second experiment, where the operator applies a pulse wave to the first input and a step signal to the second input.
Input and Output Data from Experiment 2

Plotting the data, as described in Plotting the Input/Output Data, shows that the inputs and the outputs have nonzero equilibrium values. In this portion of the tutorial, you subtract equilibrium values from the data.
The reason you subtract the mean values from each signal is because, typically, you build linear models that describe the responses for deviations from a physical equilibrium. With steady-state data, it is reasonable to assume that the mean levels of the signals correspond to such an equilibrium. Thus, you can seek models around zero without modeling the absolute equilibrium levels in physical units.
Zoom in on the plots to see that the earliest moment when the operator applies a disturbance to the inputs occurs after 25 minutes of steady-state conditions (or after the first 50 samples). Thus, the average value of the first 50 samples represents the equilibrium conditions.
Use the following commands to remove the equilibrium values from the inputs and the outputs in both experiments:
% Remove the equilibrium values from inputs % and outputs in both experiments: Input_exp1 = Input_exp1-... ones(size(Input_exp1,1),1)*mean(Input_exp1(1:50,:)); Output_exp1 = Output_exp1-... mean(Output_exp1(1:50,:)); Input_exp2 = Input_exp2-... ones(size(Input_exp2,1),1)*mean(Input_exp2(1:50,:)); Output_exp2 = Output_exp2-... mean(Output_exp2(1:50,:));
Note The ones command replicates the two mean values, one for each input, in a two-dimensional array. |
The System Identification Toolbox data objects, iddata and idfrd, encapsulate both data values and data properties into a single entity. You can use the System Identification Toolbox commands to conveniently manipulate these data objects as single entities.
In this portion of the tutorial, you create two iddata objects, one for each of the two experiments. You use the data from Experiment 1 for model estimation, and the data from Experiment 2 for model validation. You work with two independent data sets because you use one data set for model estimation and the other for model validation.
Note When two independent data sets are not available, you can split one data set into two parts, assuming that each part contains enough information to adequately represent the system dynamics. |
You must have already loaded the sample data into the MATLAB workspace, as described in Loading Data into the MATLAB Workspace.
Use these commands to create two data objects, ze and zv:
% Create two data objects, ze and zv. Ts = 0.5; % Sampling interval is 0.5 min ze = iddata(Output_exp1,Input_exp1,Ts); zv = iddata(Output_exp2,Input_exp2,Ts);
ze contains data from Experiment 1 and zv contains data from Experiment 2. Ts is the sampling interval.
The iddata constructor requires three arguments for time-domain data and has the following syntax:
data_obj = iddata(output,input,sampling_interval);
To view the properties of an iddata object, use the get command. For example, type this command to get the properties of the estimation data:
get(ze)
To learn more about the properties of this data object, see the iddata reference page.
To modify data properties, you can use dot notation or the set command. For example, to assign channel names and units that label plot axes, type the following syntax in the MATLAB Command Window:
% Set time units to minutes
ze.TimeUnit = 'min';
% Set names of input channels
ze.InputName = {'ConsumptionRate','Current'};
% Set units for input variables
ze.InputUnit = {'kg/min','A'};
% Set name of output channel
ze.OutputName = 'Production';
% Set unit of output channel
ze.OutputUnit = 'mg/min';
% Set validation data properties
zv.TimeUnit = 'min';
zv.InputName = {'ConsumptionRate','Current'};
zv.InputUnit = {'kg/min','A'};
zv.OutputName = 'Production';
zv.OutputUnit = 'mg/min';You can verify that the InputName property of ze is changed, or "index into" this property, by typing the following syntax:
ze.inputname
Tip Property names, such as InputUnit, are not case sensitive. You can also abbreviate property names that start with Input or Output by substituting u for Input and y for Output in the property name. For example, OutputUnit is equivalent to yunit. |
You can plot iddata objects using the MATLAB plot command:
plot(ze) % Plot the estimation data
This opens the following plot. The bottom axes show the first input ConsumptionRate, and the top axes show the output ProductionRate.
Input 1 and Output for ze

For multivariable data, only one input/output pair appears on the plot at a time. To view the second input Current, select the MATLAB Figure window, and press Enter to update the plot.
Tip For plots of data with multiple inputs and outputs, press Enter to view the next input/output pair. |
Input 2 and Output for ze

To plot the validation data in a new MATLAB Figure window, type the following commands in the MATLAB Command Window:
figure % Open a new MATLAB Figure window plot(zv) % Plot the validation data
Input 1 and Output for zv

Select the MATLAB Figure window, and press Enter to view the second input on the plot.
Input 2 and Output for zv

Zoom in on the plots to see that the experiment process amplifies the first input (ConsumptionRate) by a factor of 2, and amplifies the second input (Current) by a factor of 10.
Before you begin, create a new data set that contains only the first 1000 samples of the original estimation and validation data sets to speed up the calculations:
Ze1 = ze(1:1000); Zv1 = zv(1:1000);
For more information about indexing into iddata objects, see the corresponding reference page.
![]() | About This Tutorial | Estimating Step- and Frequency-Response Models | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |