Products & Services Solutions Academia Support User Community Company

Learn more about System Identification Toolbox   

Preparing Data

Loading Data into the MATLAB Workspace

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:

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).

Plotting the Input/Output Data

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

Removing Equilibrium Values from the Data

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,:));

Using Objects to Represent Data for System Identification

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.

Creating iddata Objects

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

Plotting the Data in a Data Object

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.

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.

Selecting a Subset of the Data

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.

  


Recommended Products

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