Accelerating the pace of engineering and science

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 sampling time interval. 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)$

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 sampling interval.

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 sampling interval. 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 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 sampling 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:

 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. FrequencyUnit is a string that specifies the units of the frequency vector in the Frequency property. Set FrequencyUnit to 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 Information about the estimation process. Report contains the following fields:Status: Whether model was obtained by construction, estimated, or modified after estimation.Method: Name of estimation method used.WindowSize: If the model was estimated by spa, spafdr, or etfe, the size of window (input argument M, the resolution parameter) that was used. This is scalar or a vector.DataUsed: Attributes of data used for estimation, such as name, sampling time, and intersample behavior. 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 sampling period, 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 sampling period Ts. For example, InputDelay = 3 means a delay of three sampling periods. 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 Sampling time. For continuous-time models, Ts = 0. For discrete-time models, Ts is a positive scalar representing the sampling period expressed in the unit specified by the TimeUnit property of the model. To denote a discrete-time model with unspecified sampling time, set Ts = -1. Changing this property does not discretize or resample the model. Use c2d and d2c to convert between continuous- and discrete-time representations. Use d2d to change the sampling time of a discrete-time system. Default: 1 TimeUnit String representing the unit of the time variable. This property specifies the units for the time variable, the sampling time Ts, and any time delays in the model. Use any 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. Set InputName to a string for single-input model. For a multi-input model, set InputName to a cell array of strings. 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: Empty string '' for all input channels InputUnit Input channel units. Use InputUnit to keep track of input signal units. For a single-input model, set InputUnit to a string. For a multi-input model, set InputUnit to a cell array of strings. InputUnit has no effect on system behavior. Default: Empty string '' 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. Set OutputName to a string for single-output model. For a multi-output model, set OutputName to a cell array of strings. 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 to 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: Empty string '' for all input channels OutputUnit Output channel units. Use OutputUnit to keep track of output signal units. For a single-output model, set OutputUnit to a string. For a multi-output model, set OutputUnit to a cell array of strings. OutputUnit has no effect on system behavior. Default: Empty string '' for all input 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. Set Name to a string to label the system. Default: '' Notes Any text that you want to associate with the system. Set Notes to a string or a cell array of strings. Default: {} UserData Any type of data you wish to associate with system. Set UserData to 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. Default: []

To view the properties of the idfrd object, you can use the get command. The following example shows how to create an idfrd object that contains 100 frequency-response values with a sampling time interval of 0.08 s and get its properties:

```% Create the idfrd data object
fr_data = idfrd(response,f,0.08)
% Get property values of data
get(fr_data)
```

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

To change property values for an existing idfrd object, use the set command or dot notation. For example, to change the name of the idfrd object, type the following command sequence at the prompt:

```% Set the name of the f_data object
set(fr_data,'name','DC_Converter')
% Get fr_data properties and values
get(fr_data)                    ```

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

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

Compare the results from spectral analysis and an ARMAX model.

```load iddata1 z1;
m = armax(z1,[2 2 2 1]);
g = spa(z1)
g = spafdr(z1,[],{1e-3,10})
bode(g,m)
```