Main Content

Representing Data in MATLAB Workspace

Time-Domain Data Representation

Time-domain data consists of one or more input variables u(t) and one or more output variables y(t), sampled as a function of time. If there is no input variable, see Time-Series Data Representation.

You can organize time-domain input/output data in one of three data types:

  1. A timetable that contains a time variable and any number of input and output channel variables

  2. A pair of numeric matrices that contain the input and output data separately

  3. An iddata object that contains properties such as input and output data, sample time, and intersample behavior for continuous models

For all these data types, the general data format requirements, as implemented in the three data types, are as follows:

  • For single-input/single-output (SISO) data, the sampled data values must be double column vectors with lengths equal to the number of data samples (measurements).

  • For multi-input/multi-output (MIMO) data with Nu inputs and Ny outputs, and Ns number of data samples:

    • The input data must be an Ns-by-Nu matrix

    • The output data must be an Ns-by-Ny matrix

To use time-domain data for identification, you must know the sample time. If you are working with uniformly sampled data, use the actual sample time from your experiment. Each data value is assigned a time instant, which is calculated from the start time and sample time. You can work with nonuniformly sampled data only at the command line by specifying a vector of time instants using the SamplingInstants property of iddata, as described in Constructing an iddata Object for Time-Domain Data or by using the time variable in a timetable. Typically, estimation algorithms require uniformly sampled data.

If the data is contained in numeric matrices, the matrices provide no sample-time knowledge. The data must be uniformly sampled in this case. The software assumes the sample time is 1 second unless you specify a different sample time explicitly in the function syntax. Estimating continuous models using matrix-based data is not recommended.

For continuous-time models, you must also know the input intersample behavior, such as zero-order hold and first-order-hold.

For more information about importing data into MATLAB®, see Data Import and Export.

After you have the variables in the MATLAB workspace, import them into the System Identification app or create a data object for working at the command line. For more information, see Import Time-Domain Data into the App, Data Domains and Data Types in System Identification Toolbox, and Representing Time- and Frequency-Domain Data Using iddata Objects.

Time-Series Data Representation

Time-series data is time-domain or frequency-domain data that consist of one or more outputs y(t) with no corresponding input. For more information on how to obtain identification data, see Ways to Obtain Identification Data.

You must organize time-series data in the following format:

  • For single-input/single-output (SISO) data, the output data values must be a column vector.

  • For data with Ny outputs, the output is an Ns-by-Ny matrix, where Ns is the number of output data samples (measurements).

To use time-series data for identification, you also need the sample time. If you are working with uniformly sampled data, use the actual sample time from your experiment. Each data value is assigned a sample time, which is calculated from the start time and the sample time. 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, or by using the time variable in a timetable. Note that model estimation cannot be performed using non-uniformly sampled data.

For more information about importing data into the MATLAB workspace, see Data Import and Export.

After you have the variables in the MATLAB workspace, import them into the System Identification app or create a data object for working at the command line. For more information, see Import Time-Domain Data into the App and Representing Time- and Frequency-Domain Data Using iddata Objects.

For information about estimating time-series model parameters, see Time Series Analysis.

Frequency-Domain Data Representation

Frequency-domain data consists of either transformed input and output time-domain signals or system frequency response sampled as a function of the independent variable frequency.

Frequency-Domain Input/Output Signal Representation

What Is Frequency-Domain Input/Output Signal?.  Frequency-domain data is the Fourier transform of the input and output time-domain signals. For continuous-time signals, the Fourier transform over the entire time axis is defined as follows:

Y(iw)=y(t)eiwtdtU(iw)=u(t)eiwtdt

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 sample time T, the frequency-domain output Y(eiw) and input U(eiw) is the time-discrete Fourier transform (TDFT):

Y(eiwT)=Tk=1Ny(kT)eiwkT

In this example, k = 1,2,...,N, where N is the number of samples in the sequence.

Note

This form only discretizes the time. The frequency is continuous.

In practice, the Fourier transform cannot be handled for all continuous frequencies and you must specify a finite number of frequencies. The discrete Fourier transform (DFT) of time-domain data for N equally spaced frequencies between 0 and the sampling frequency 2π/N is:

Y(eiwnT)=k=1Ny(kT)eiwnkTwn=2πnT    n=0,1,2,,N1

The DFT is useful because it can be calculated very efficiently using the fast Fourier transform (FFT) method. Fourier transforms of the input and output data are complex numbers.

For more information on how to obtain identification data, see Ways to Obtain Identification Data.

How to Represent Frequency-Domain Data in MATLAB.  You must organize frequency-domain data in the following format:

  • Input and output

    • For single-input/single-output (SISO) data:

      • The input data must be a column vector containing the values u(eiωkT)

      • The output data must be a column vector containing the values y(eiωkT)

      k=1, 2, ..., Nf, where Nf is the number of frequencies.

    • For multi-input/multi-output data with Nu inputs, Ny outputs and Nf frequency measurements:

      • The input data must be an Nf-by-Nu matrix

      • The output data must be an Nf-by-Ny matrix

  • Frequencies

    • Must be a column vector.

For more information about importing data into the MATLAB workspace, see Data Import and Export.

After you have the variables in the MATLAB workspace, import them into the System Identification app or create a data object for working at the command line. For more information, see Importing Frequency-Domain Input/Output Signals into the App and Representing Time- and Frequency-Domain Data Using iddata Objects.

Frequency-Response Data Representation

What Is Frequency-Response Data?.  Frequency-response data, also called frequency-function data, consists of complex frequency-response values for a linear system characterized by its transfer function G. Frequency-response data tells you how the system handles sinusoidal inputs. You can measure frequency-response data values directly using a spectrum analyzer, for example, which provides a compact representation of the input-output relationship (compared to storing input and output independently).

The transfer function G is an operator that takes the input u of a linear system to the output y:

y=Gu

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.

For a discrete-time system sampled with a time interval T, the transfer function relates the Z-transforms of the input U(z) and output Y(z):

Y(z)=G(z)U(z)

In this case, the frequency function G(eiwT) is the transfer function G(z) evaluated on the unit circle. The argument of the frequency function G(eiwT) is scaled by the sample time T to make the frequency function periodic with the sampling frequency 2πT.

When the input to the system is a sinusoid of a specific frequency, the output is also a sinusoid with the same frequency. The amplitude of the output is |G| times the amplitude of the input. The phase of the shifted from the input by φ=argG. G is evaluated at the frequency of the input sinusoid.

Frequency-response data represents a (nonparametric) model of the relationship between the input and the outputs as a function of frequency. You might use such a model, which consists of a table or plot of values, to study the system frequency response. However, this model is not suitable for simulation and prediction. You should create parametric model from the frequency-response data.

For more information on how to obtain identification data, see Ways to Obtain Identification Data.

How to Represent Frequency-Response Data in MATLAB.  You can represent frequency-response data in two ways:

  • Complex-values G(e) , for given frequencies ω

  • Amplitude |G| and phase shift φ=argG values

You can import both the formats directly in the System Identification app. At the command line, you must represent complex data using an frd or idfrd object. If the data is in amplitude and phase format, convert it to complex frequency-response vector using h(ω) = A(ω)ejϕ(ω).

You must organize frequency-response data in the following format:

Frequency-Response Data RepresentationFor Single-Input Single-Output (SISO) DataFor Multi-Input Multi-Output (MIMO) Data
Complex Values
  • Frequency function must be a column vector.

  • Frequency values must be a column vector.

  • Frequency function must be an Ny-by-Nu-by-Nf array, where Nu is the number of inputs, Ny is the number of outputs, and Nf is the number of frequency measurements.

  • Frequency values must be a column vector.

Amplitude and phase shift values
  • Amplitude and phase must each be a column vector.

  • Frequency values must be a column vector.

  • Amplitude and phase must each be an Ny-by-Nu-by-Nf array, where Nu is the number of inputs, Ny is the number of outputs, and Nf is the number of frequency measurements.

  • Frequency values must be a column vector.

For more information about importing data into the MATLAB workspace, see Data Import and Export.

After you have the variables in the MATLAB workspace, import them into the System Identification app or create a data object for working at the command line. For more information about importing data into the app, see Importing Frequency-Response Data into the App. To learn more about creating a data object, see Representing Frequency-Response Data Using idfrd Objects.