## 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 must organize time-domain input/output data in the following format:

• For single-input/single-output (SISO) data, the sampled data values must be double column vectors.

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

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

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

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.

### 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. Note that model estimation cannot be performed using non-uniformly sampled data.

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:

`$\begin{array}{l}Y\left(iw\right)=\underset{-\infty }{\overset{\infty }{\int }}y\left(t\right){e}^{-iwt}dt\\ U\left(iw\right)=\underset{-\infty }{\overset{\infty }{\int }}u\left(t\right){e}^{-iwt}dt\end{array}$`

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\left({e}^{iwT}\right)=T\sum _{k=1}^{N}y\left(kT\right){e}^{-iwkT}$`

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:

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\left({e}^{i\omega kT}\right)$

• The output data must be a column vector containing the values $y\left({e}^{i\omega kT}\right)$

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.

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\left(s\right)=G\left(s\right)U\left(s\right)$`

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\left(z\right)=G\left(z\right)U\left(z\right)$`

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\pi }{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 $\phi =\mathrm{arg}G$. 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 $\phi =\mathrm{arg}G$ 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.