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

The following tables summarize time-vector and frequency-vector properties, respectively, and provides usage examples. In each example, data is an iddata object.

    Note:   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.

iddata Time-Vector Properties

PropertyDescriptionSyntax Example
Ts

Sampling time interval.

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

To set the sampling interval to 0.05:

set(data,'ts',0.05)

or

data.ts = 0.05
Tstart

Starting time of the experiment.

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

To change starting time of the first data sample to 24:

data.Tstart = 24

Time units are set by the property TimeUnit.

SamplingInstants

Time values in the time vector, computed from the properties Tstart and Ts.

  • For a single experiment, SamplingInstants is an N-by-1 vector.

  • For multiexperiement data with Ne experiments, this property is a 1-by-Ne cell array, and each cell contains the sampling instants of the corresponding experiment.

To retrieve the time vector for iddata object data, use:

get(data,'sa')

To plot the input data as a function of time:

plot(data.sa,data.u)

    Note:   sa is the first two letters of the SamplingInstants property that uniquely identifies this property.

TimeUnitUnit of time. Specify as one of the following: 'nanoseconds', 'microseconds', 'milliseconds', 'seconds', 'minutes', 'hours', 'days', 'weeks', 'months', and 'years'.

To change the unit of the time vector to milliseconds:

data.ti = 'milliseconds'

iddata Frequency-Vector Properties

PropertyDescriptionSyntax Example
Frequency

Frequency values at which the Fourier transforms of the signals are defined.

  • For a single experiment, Frequency is a scalar value.

  • For multiexperiement data with Ne experiments, Frequency is a 1-by-Ne cell array, and each cell contains the frequencies of the corresponding experiment.

To specify 100 frequency values in log space, ranging between 0.1 and 100, use the following syntax:

data.freq =
 logspace(-1,2,100)
FrequencyUnit

Unit of Frequency. Specify as one of the following: be one of the following: 'rad/TimeUnit', 'cycles/TimeUnit', 'rad/s', 'Hz', 'kHz', 'MHz', 'GHz', and, 'rpm'. Default: ‘rad/TimeUnit'

For multi-experiement data with Ne experiments, Units is a 1-by-Ne cell array, and each cell contains the frequency unit for each experiment.

Set the frequency unit to Hz:
data.FrequencyUnit = 'Hz'
Note that changing the frequency unit does not scale the frequency vector. For a proper translation of units, use chgFreqUnit.

Naming, Adding, and Removing Data Channels

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.

Naming Channels

The iddata properties InputName and OutputName store the channel names for the input and output signals. When you plot the data, you use channel names to select the variable displayed on the plot. If you have multivariate data, it is helpful to assign a name to each channel that describes the measured variable. For more information about selecting channels on a plot, see Selecting Measured and Noise Channels in Plots.

You can use the set command to specify the names of individual channels. For example, suppose data contains two input channels (voltage and current) and one output channel (temperature). To set these channel names, use the following syntax:

set(data,'InputName',{'Voltage','Current'},
         'OutputName','Temperature')

    Tip   You can also specify channel names as follows:

    data.una = {'Voltage','Current')
    data.yna = 'Temperature'

    una is equivalent to the property InputName, and yna is equivalent to OutputName.

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.u(:,5) = Input5;

Input5 must have the same number of rows as the other input channels. In this example, data.u(:,5) references all samples as (indicated by :) of the input signal u and sets the values of the fifth channel. This channel is created when assigning its value to Input5.

You can also combine input channels and output channels of several iddata objects into one iddata object using concatenation. For more information, see Increasing Number of Channels or Data Points of iddata Objects.

Modifying Channel Data

After you create an iddata object, you can modify or remove specific input and output channels, if needed. You can accomplish this by subreferencing the input and output matrices and assigning new values.

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). To replace data such that it only contains samples in y3, u1, and u4, type the following at the prompt:

data = data(:,3,[1 4])

The resulting data object contains one output channel and two input channels.

Was this topic helpful?