# idfrd

Frequency-response data or model

## Syntax

h = idfrd(Response,Freq,Ts)
h = idfrd(Response,Freq,Ts,'CovarianceData',Covariance,'SpectrumData',Spec,'NoiseCovariance',Speccov)
h = idfrd(Response,Freq,Ts,...
'P1',V1,'PN',VN)
h = idfrd(mod)
h = idfrd(mod,Freqs)

## Description

h = idfrd(Response,Freq,Ts) constructs an idfrd object that stores the frequency response, Response, of a linear system at frequency values, Freq. Ts is the sample time. For a continuous-time system, set Ts=0.

h = idfrd(Response,Freq,Ts,'CovarianceData',Covariance,'SpectrumData',Spec,'NoiseCovariance',Speccov) also stores the uncertainty of the response, Covariance, the spectrum of the additive disturbance (noise), Spec, and the covariance of the noise, Speccov.

h = idfrd(Response,Freq,Ts,...
'P1',V1,'PN',VN)
constructs an idfrd object that stores a frequency-response model with properties specified by the idfrd model property-value pairs.

h = idfrd(mod) converts a System Identification Toolbox™ or Control System Toolbox™ linear model to frequency-response data at default frequencies, including the output noise spectra and their covariance.

h = idfrd(mod,Freqs) converts a System Identification Toolbox or Control System Toolbox linear model to frequency-response data at frequencies Freqs.

For a model

$y\left(t\right)=G\left(q\right)u\left(t\right)+H\left(q\right)e\left(t\right)$

idfrd object stores the transfer function estimate $G\left({e}^{i\omega }\right)$, as well as the spectrum of the additive noise (Φv) at the output.

${\Phi }_{v}\left(\omega \right)=\lambda T{|H\left(e{}^{i\omega T}\right)|}^{2}$

where λ is the estimated variance of e(t), and T is the sample time.

For a continuous-time system, the noise spectrum is given by:

${\Phi }_{v}\left(\omega \right)=\lambda {|H\left(e{}^{i\omega }\right)|}^{2}$

### Creating idfrd from Given Responses

Response is a 3-D array of dimension ny-by-nu-by-Nf, with ny being the number of outputs, nu the number of inputs, and Nf the number of frequencies (that is, the length of Freqs). Response(ky,ku,kf) is thus the complex-valued frequency response from input ku to output ky at frequency $\omega$=Freqs(kf). When defining the response of a SISO system, Response can be given as a vector.

Freqs is a column vector of length Nf containing the frequencies of the response.

Ts is the sample time. Ts = 0 means a continuous-time model.

Intersample behavior: For discrete-time frequency response data (Ts>0), you can also specify the intersample behavior of the input signal that was in effect when the samples were collected originally from an experiment. To specify the intersample behavior, use:

mf = idfrd(Response,Freq,Ts,'InterSample','zoh');

For multi-input systems, specify the intersample behavior using an Nu-by-1 cell array, where Nu is the number of inputs. The InterSample property is irrelevant for continuous-time data.

Covariance is a 5-D array containing the covariance of the frequency response. It has dimension ny-by-nu-by-Nf-by-2-by-2. The structure is such that Covariance(ky,ku,kf,:,:) is the 2-by-2 covariance matrix of the response Response(ky,ku,kf). The 1-1 element is the variance of the real part, the 2-2 element is the variance of the imaginary part, and the 1-2 and 2-1 elements are the covariance between the real and imaginary parts. squeeze(Covariance(ky,ku,kf,:,:)) thus gives the covariance matrix of the corresponding response.

The format for spectrum information is as follows:

spec is a 3-D array of dimension ny-by-ny-by-Nf, such that spec(ky1,ky2,kf) is the cross spectrum between the noise at output ky1 and the noise at output ky2, at frequency Freqs(kf). When ky1 = ky2 the (power) spectrum of the noise at output ky1 is thus obtained. For a single-output model, spec can be given as a vector.

speccov is a 3-D array of dimension ny-by-ny-by-Nf, such that speccov(ky1,ky1,kf) is the variance of the corresponding power spectrum.

If only SpectrumData is to be packaged in the idfrd object, set Response = [].

### Converting to idfrd

An idfrd object can also be computed from a given linear identified model, mod.

If the frequencies Freqs are not specified, a default choice is made based on the dynamics of the model mod.

Estimated covariance:

• If you obtain mod by identification, the software computes the estimated covariance for the idfrd object from the uncertainty information in mod. The software uses the Gauss approximation formula for this calculation for all model types, except grey-box models. For grey-box models (idgrey), the software applies numerical differentiation. The step sizes for the numerical derivatives are determined by nuderst.

• If you create mod by using commands such as idss, idtf, idproc, idgrey, or idpoly, then the software sets CovarianceData to [].

Delay treatment: If mod contains delays, then the software assigns the delays of the idfrd object, h, as follows:

• h.InputDelay = mod.InputDelay

• h.IODelay = mod.IODelay+repmat(mod.OutputDelay,[1,nu])

The expression repmat(mod.OutputDelay,[1,nu]) returns a matrix containing the output delay for each input/output pair.

Frequency responses for submodels can be obtained by the standard subreferencing, h = idfrd(m(2,3)). h = idfrd(m(:,[])) gives an h that just contains SpectrumData.

The idfrd models can be graphed with bode, spectrum, and nyquist, which accept mixtures of parametric models, such as idtf and idfrd models as arguments. Note that spa, spafdr, and etfe return their estimation results as idfrd objects.

## Constructor

The idfrd object represents complex frequency-response data. Before you can create an idfrd object, you must import your data as described in Frequency-Response Data Representation.

### Note

The idfrd object can only encapsulate one frequency-response data set. It does not support the iddata equivalent of multiexperiment data.

Use the following syntax to create the data object fr_data:

fr_data = idfrd(response,f,Ts)

Suppose that ny is the number of output channels, nu is the number of input channels, and nf is a vector of frequency values. response is an ny-by-nu-by-nf 3-D array. f is the frequency vector that contains the frequencies of the response.Ts is the sample time, which is used when measuring or computing the frequency response. If you are working with a continuous-time system, set Ts to 0.

response(ky,ku,kf), where ky, ku, and kf reference the kth output, input, and frequency value, respectively, is interpreted as the complex-valued frequency response from input ku to output ky at frequency f(kf).

You can specify object properties when you create the idfrd object using the constructor syntax:

fr_data = idfrd(response,f,Ts,
'Property1',Value1,...,'PropertyN',ValueN)

## Properties

idfrd object properties include:

## Subreferencing

The different channels of the idfrd are retrieved by subreferencing.

h(outputs,inputs)

h(2,3) thus contains the response data from input channel 3 to output channel 2, and, if applicable, the output spectrum data for output channel 2. The channels can also be referred to by their names, as in h('power',{'voltage','speed'}).

## Horizontal Concatenation

h = [h1,h2,...,hN]

creates an idfrd model h, with ResponseData containing all the input channels in h1,...,hN. The output channels of hk must be the same, as well as the frequency vectors. SpectrumData is ignored.

## Vertical Concatenation

h = [h1;h2;... ;hN]

creates an idfrd model h with ResponseData containing all the output channels in h1, h2,...,hN. The input channels of hk must all be the same, as well as the frequency vectors. SpectrumData is also appended for the new outputs. The cross spectrum between output channels of h1, h2,...,hN is then set to zero.

## Converting to iddata

You can convert an idfrd object to a frequency-domain iddata object by

Data = iddata(Idfrdmodel)

Seeiddata.

## Examples

collapse all

To view and modify a property of an idfrd object, use dot notation.

The following example shows how to create an idfrd object that contains 100 frequency-response values with a sample time of 0.08s and get its properties.

Create an idfrd object.

f = logspace(-1,1,100);
[mag, phase] = bode(idtf([1 .2],[1 2 1 1]),f);
response = mag.*exp(1j*phase*pi/180);
fr_data = idfrd(response,f,0.08);

response and f are variables in the MATLAB Workspace browser, representing the frequency-response data and frequency values, respectively.

You can use get(fr_data) to view all properties of the idfrd object. You can specify properties when you create an idfrd object using the constructor syntax. For example, fr_data = idfrd(y,u,Ts,'Property1',Value1,...,'PropertyN',ValueN) .

Use dot notation to change property values for an existing idfrd object. For example, change the name of the idfrd object.

fr_data.Name = 'DC_Converter';

If you import fr_data into the System Identification app, this data is named DC_Converter in the app, and not the variable name fr_data .