Documentation

# 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 `k`th 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:

 `ResponseData` Frequency response data. The `'ResponseData'` property stores the frequency response data as a 3-D array of complex numbers. For SISO systems, `'ResponseData'` is a vector of frequency response values at the frequency points specified in the `'Frequency'` property. For MIMO systems with `Nu` inputs and `Ny` outputs, `'ResponseData'` is an array of size `[Ny Nu Nw]`, where `Nw` is the number of frequency points. `Frequency` Frequency points of the frequency response data. Specify `Frequency` values in the units specified by the `FrequencyUnit` property. `FrequencyUnit` Frequency units of the model. Units of the frequency vector in the `Frequency` property, specified as one of the following values: `'rad/TimeUnit'``'cycles/TimeUnit'``'rad/s'``'Hz'``'kHz'``'MHz'``'GHz'``'rpm'` The units `'rad/TimeUnit'` and `'cycles/TimeUnit'` are relative to the time units specified in the `TimeUnit` property. Changing this property changes the overall system behavior. Use `chgFreqUnit` to convert between frequency units without modifying system behavior. Default: `'rad/TimeUnit'` `SpectrumData` Power spectra and cross spectra of the system output disturbances (noise). Specify `SpectrumData` as a 3-D array of complex numbers. Specify `SpectrumData` as a 3-D array with dimension `ny`-by-`ny`-by-`Nf`. Here, `ny` is the number of outputs and `Nf` is the number of frequency points. `SpectrumData(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, specify `SpectrumData` as a vector. `CovarianceData` Response data covariance matrices. Specify `CovarianceData` as a 5-D array with dimension `ny`-by-`nu`-by-`Nf`-by-2-by-2. Here, `ny`, `nu`, and `Nf` are the number of outputs, inputs and frequency points, respectively. `CovarianceData(ky,ku,kf,:,:)` is the 2-by-2 covariance matrix of the response data `ResponseData(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,:,:))`` `NoiseCovariance` Power spectra variance. Specify `NoiseCovariance` as a 3-D array with dimension `ny`-by-`ny`-by-`Nf`. Here, `ny` is the number of outputs and `Nf` is the number of frequency points. `NoiseCovariance(ky1,ky1,kf)` is the variance of the corresponding power spectrum. To eliminate the influence of the noise component from the model, specify `NoiseVariance` as `0`. Zero variance makes the predicted output the same as the simulated output. `Report` Summary report that contains information about the estimation options and results when the frequency-response model is obtained using estimation commands, such as `spa`, `spafdr`, and `etfe`. Use `Report` to query a model for how it was estimated, including its: Estimation methodEstimation optionsSearch termination conditionsEstimation data fit and other quality metrics The contents of `Report` are irrelevant if the model was created by construction. ```f = logspace(-1,1,100); [mag,phase] = bode(idtf([1 .2],[1 2 1 1]),f); response = mag.*exp(1j*phase*pi/180); m = idfrd(response,f,0.08); m.Report.Method``` ```ans = ''``` If you obtain the frequency-response model using estimation commands, the fields of `Report` contain information on the estimation data, options, and results. ```load iddata3; m = spa(z3); m.Report.Method``` ```ans = SPA``` `Report` is a read-only property. For more information on this property and how to use it, see the Output Arguments section of the corresponding estimation command reference page and Estimation Report. `InterSample` Input intersample behavior. Specifies the behavior of the input signals between samples for transformations between discrete-time and continuous-time. This property is meaningful for discrete-time `idfrd` models only. Set `InterSample` to one of the following: `'zoh'` — The input signal used for construction/estimation of the frequency response data was subject to a zero-order-hold filter.`'foh'` — The input signal was subject to a first-order-hold filter.`'bl'` — The input signal has no power above the Nyquist frequency (`pi/sys.Ts` rad/s). This is typically the case when the input signal is measured experimentally using an anti-aliasing filter and a sampler. Ideally, treat the data as continuous-time. That is, if the signals used for the estimation of the frequency response were subject to anti-aliasing filters, set `sys.Ts` to zero. For multi-input data, specify `InterSample` as an Nu-by-1 cell array, where Nu is the number of inputs. `IODelay` Transport delays. `IODelay` is a numeric array specifying a separate transport delay for each input/output pair. For continuous-time systems, specify transport delays in the time unit stored in the `TimeUnit` property. For discrete-time systems, specify transport delays in integer multiples of the sample time, `Ts`. For a MIMO system with `Ny` outputs and `Nu` inputs, set `IODelay` to a `Ny`-by-`Nu` array. Each entry of this array is a numerical value that represents the transport delay for the corresponding input/output pair. You can also set `IODelay` to a scalar value to apply the same delay to all input/output pairs. Default: `0` for all input/output pairs `InputDelay` Input delay for each input channel, specified as a scalar value or numeric vector. For continuous-time systems, specify input delays in the time unit stored in the `TimeUnit` property. For discrete-time systems, specify input delays in integer multiples of the sample time `Ts`. For example, ```InputDelay = 3``` means a delay of three sample times. For a system with `Nu` inputs, set `InputDelay` to an `Nu`-by-1 vector. Each entry of this vector is a numerical value that represents the input delay for the corresponding input channel. You can also set `InputDelay` to a scalar value to apply the same delay to all channels. Default: 0 `OutputDelay` Output delays. For identified systems, like `idfrd`, `OutputDelay` is fixed to zero. `Ts` Sample time. For continuous-time models, `Ts = 0`. For discrete-time models, `Ts` is a positive scalar representing the sample time expressed in the unit specified by the `TimeUnit` property of the model. To denote a discrete-time model with unspecified sample time, set `Ts = -1`. Changing this property does not discretize or resample the model. Default: `1` `TimeUnit` Units for the time variable, the sample time `Ts`, and any time delays in the model, specified as one of the following values:`'nanoseconds'``'microseconds'``'milliseconds'``'seconds'` `'minutes'``'hours'``'days'``'weeks'``'months'``'years'` Changing this property has no effect on other properties, and therefore changes the overall system behavior. Use `chgTimeUnit` to convert between time units without modifying system behavior. Default: `'seconds'` `InputName` Input channel names, specified as one of the following: Character vector — For single-input models, for example, `'controls'`.Cell array of character vectors — For multi-input models. Alternatively, use automatic vector expansion to assign input names for multi-input models. For example, if `sys` is a two-input model, enter: `sys.InputName = 'controls';` The input names automatically expand to `{'controls(1)';'controls(2)'}`. When you estimate a model using an `iddata` object, `data`, the software automatically sets `InputName` to `data.InputName`. You can use the shorthand notation `u` to refer to the `InputName` property. For example, `sys.u` is equivalent to `sys.InputName`. Input channel names have several uses, including: Identifying channels on model display and plotsExtracting subsystems of MIMO systemsSpecifying connection points when interconnecting models Default: `''` for all input channels `InputUnit` Input channel units, specified as one of the following: Character vector — For single-input models, for example, `'seconds'`.Cell array of character vectors — For multi-input models. Use `InputUnit` to keep track of input signal units. `InputUnit` has no effect on system behavior. Default: `''` for all input channels `InputGroup` Input channel groups. The `InputGroup` property lets you assign the input channels of MIMO systems into groups and refer to each group by name. Specify input groups as a structure. In this structure, field names are the group names, and field values are the input channels belonging to each group. For example: ```sys.InputGroup.controls = [1 2]; sys.InputGroup.noise = [3 5];``` creates input groups named `controls` and `noise` that include input channels 1, 2 and 3, 5, respectively. You can then extract the subsystem from the `controls` inputs to all outputs using: `sys(:,'controls')` Default: Struct with no fields `OutputName` Output channel names, specified as one of the following: Character vector — For single-output models. For example, `'measurements'`.Cell array of character vectors — For multi-output models. Alternatively, use automatic vector expansion to assign output names for multi-output models. For example, if `sys` is a two-output model, enter: `sys.OutputName = 'measurements';` The output names automatically expand to `{'measurements(1)';'measurements(2)'}`. When you estimate a model using an `iddata` object, `data`, the software automatically sets `OutputName` to `data.OutputName`. You can use the shorthand notation `y` to refer to the `OutputName` property. For example, `sys.y` is equivalent to `sys.OutputName`. Output channel names have several uses, including: Identifying channels on model display and plotsExtracting subsystems of MIMO systemsSpecifying connection points when interconnecting models Default: `''` for all output channels `OutputUnit` Output channel units, specified as one of the following: Character vector — For single-output models. For example, `'seconds'`.Cell array of character vectors — For multi-output models. Use `OutputUnit` to keep track of output signal units. `OutputUnit` has no effect on system behavior. Default: `''` for all output channels `OutputGroup` Output channel groups. The `OutputGroup` property lets you assign the output channels of MIMO systems into groups and refer to each group by name. Specify output groups as a structure. In this structure, field names are the group names, and field values are the output channels belonging to each group. For example: ```sys.OutputGroup.temperature = [1]; sys.InputGroup.measurement = [3 5];``` creates output groups named `temperature` and `measurement` that include output channels 1, and 3, 5, respectively. You can then extract the subsystem from all inputs to the `measurement` outputs using: `sys('measurement',:)` Default: Struct with no fields `Name` System name, specified as a character vector. For example, `'system_1'`. Default: `''` `Notes` Any text that you want to associate with the system, stored as a string or a cell array of character vectors. The property stores whichever data type you provide. For instance, if `sys1` and `sys2` are dynamic system models, you can set their `Notes` properties as follows: ```sys1.Notes = "sys1 has a string."; sys2.Notes = 'sys2 has a character vector.'; sys1.Notes sys2.Notes``` ```ans = "sys1 has a string." ans = 'sys2 has a character vector.' ``` Default: `[0×1 string]` `UserData` Any type of data you want to associate with system, specified as any MATLAB® data type. Default: `[]` `SamplingGrid` Sampling grid for model arrays, specified as a data structure. For arrays of identified linear (IDLTI) models that are derived by sampling one or more independent variables, this property tracks the variable values associated with each model. This information appears when you display or plot the model array. Use this information to trace results back to the independent variables. Set the field names of the data structure to the names of the sampling variables. Set the field values to the sampled variable values associated with each model in the array. All sampling variables should be numeric and scalar valued, and all arrays of sampled values should match the dimensions of the model array. For example, if you collect data at various operating points of a system, you can identify a model for each operating point separately and then stack the results together into a single system array. You can tag the individual models in the array with information regarding the operating point: ```nominal_engine_rpm = [1000 5000 10000]; sys.SamplingGrid = struct('rpm', nominal_engine_rpm)``` where `sys` is an array containing three identified models obtained at rpms 1000, 5000 and 10000, respectively. For model arrays generated by linearizing a Simulink® model at multiple parameter values or operating points, the software populates `SamplingGrid` automatically with the variable values that correspond to each entry in the array. For example, the Simulink Control Design™ commands `linearize` and `slLinearizer` populate `SamplingGrid` in this way. Default: `[]`

## 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) ```

See`iddata`.

## 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` .