freqresp

Frequency response over grid

Syntax

```[H,wout] = freqresp(sys) H = freqresp(sys,w) H = freqresp(sys,w,units) [H,wout,covH] = freqresp(idsys,...) ```

Description

```[H,wout] = freqresp(sys)``` returns the frequency response of the dynamic system model `sys` at frequencies `wout`. The `freqresp` command automatically determines the frequencies based on the dynamics of `sys`.

`H = freqresp(sys,w)` returns the frequency response on the real frequency grid specified by the vector `w`.

`H = freqresp(sys,w,units)` explicitly specifies the frequency units of `w` with `units`.

```[H,wout,covH] = freqresp(idsys,...)``` also returns the covariance `covH` of the frequency response of the identified model `idsys`.

Input Arguments

 `sys` Any dynamic system model or model array. `w` Vector of real frequencies at which to evaluate the frequency response. Specify frequencies in units of `rad/TimeUnit`, where `TimeUnit` is the time units specified in the `TimeUnit` property of `sys`. `units` Units of the frequencies in the input frequency vector `w`, specified as one of the following values: `'rad/TimeUnit'` — radians per the time unit specified in the `TimeUnit` property of `sys``'cycles/TimeUnit'` — cycles per the time unit specified in the `TimeUnit` property of `sys``'rad/s'``'Hz'``'kHz'``'MHz'``'GHz'``'rpm'` Default: `'rad/TimeUnit'` `idsys` Any identified model.

Output Arguments

 `H` Array containing the frequency response values. If `sys` is an individual dynamic system model having `Ny` outputs and `Nu` inputs, `H` is a 3D array with dimensions `Ny`-by-`Nu`-by-`Nw`, where `Nw` is the number of frequency points. Thus, `H(:,:,k)` is the response at the frequency `w(k)` or `wout(k)`. If `sys` is a model array of size `[Ny` `Nu` `S1` `...` `Sn]`, `H` is an array with dimensions `Ny`-by-`Nu`-by-`Nw`-by-`S1`-by-...-by-`Sn`] array. If `sys` is a frequency response data model (such as `frd`, `genfrd`, or `idfrd`), `freqresp(sys,w)` evaluates to `NaN` for values of `w` falling outside the frequency interval defined by `sys.frequency`. The `freqresp` command can interpolate between frequencies in `sys.frequency`. However, `freqresp` cannot extrapolate beyond the frequency interval defined by `sys.frequency`. `wout` Vector of frequencies corresponding to the frequency response values in `H`. If you omit `w` from the inputs to `freqresp`, the command automatically determines the frequencies of `wout` based on the system dynamics. If you specify `w`, then `wout` = `w` `covH` Covariance of the response `H`. The covariance is a 5D array where `covH(i,j,k,:,:)` contains the 2-by-2 covariance matrix of the response from the `i`th input to the `j`th output at frequency `w(k)`. The (1,1) element of this 2-by-2 matrix is the variance of the real part of the response. The (2,2) element is the variance of the imaginary part. The (1,2) and (2,1) elements are the covariance between the real and imaginary parts of the response.

Examples

collapse all

Create the following 2-input, 2-output system:

`$sys=\left[\begin{array}{cc}0& \frac{1}{s+1}\\ \frac{s-1}{s+2}& 1\end{array}\right]$`

```sys11 = 0; sys22 = 1; sys12 = tf(1,[1 1]); sys21 = tf([1 -1],[1 2]); sys = [sys11,sys12;sys21,sys22];```

Compute the frequency response of the system.

`[H,wout] = freqresp(sys);`

`H` is a 2-by-2-by-45 array. Each entry `H(:,:,k)` in `H` is a 2-by-2 matrix giving the complex frequency response of all input-output pairs of `sys` at the corresponding frequency `wout(k)`. The 45 frequencies in `wout` are automatically selected based on the dynamics of `sys`.

Create the following 2-input, 2-output system:

`$sys=\left[\begin{array}{cc}0& \frac{1}{s+1}\\ \frac{s-1}{s+2}& 1\end{array}\right]$`

```sys11 = 0; sys22 = 1; sys12 = tf(1,[1 1]); sys21 = tf([1 -1],[1 2]); sys = [sys11,sys12;sys21,sys22];```

Create a logarithmically-spaced grid of 200 frequency points between 10 and 100 radians per second.

`w = logspace(1,2,200);`

Compute the frequency response of the system on the specified frequency grid.

`H = freqresp(sys,w);`

`H` is a 2-by-2-by-200 array. Each entry `H(:,:,k)` in `H` is a 2-by-2 matrix giving the complex frequency response of all input-output pairs of `sys` at the corresponding frequency `w(k)`.

Compute the frequency response and associated covariance for an identified process model at its peak response frequency.

Load estimation data `z1`.

`load iddata1 z1`

Estimate a SISO process model using the data.

`model = procest(z1,'P2UZ');`

Compute the frequency at which the model achieves the peak frequency response gain. To get a more accurate result, specify a tolerance value of `1e-6`.

`[gpeak,fpeak] = getPeakGain(model,1e-6);`

Compute the frequency response and associated covariance for `model` at its peak response frequency.

`[H,wout,covH] = freqresp(model,fpeak);`

`H` is the response value at `fpeak` frequency, and `wout` is the same as `fpeak`.

`covH` is a 5-dimensional array that contains the covariance matrix of the response from the input to the output at frequency `fpeak`. Here `covH(1,1,1,1,1)` is the variance of the real part of the response, and `covH(1,1,1,2,2)` is the variance of the imaginary part. The `covH(1,1,1,1,2)` and `covH(1,1,1,2,1)` elements are the covariance between the real and imaginary parts of the response.

collapse all

Frequency Response

In continuous time, the frequency response at a frequency ω is the transfer function value at s = . For state-space models, this value is given by

`$H\left(j\omega \right)=D+C{\left(j\omega I-A\right)}^{-1}B$`

In discrete time, the frequency response is the transfer function evaluated at points on the unit circle that correspond to the real frequencies. `freqresp` maps the real frequencies `w(1)`,..., `w(N)` to points on the unit circle using the transformation $z={e}^{j\omega {T}_{s}}$. Ts is the sample time. The function returns the values of the transfer function at the resulting z values. For models with unspecified sample time, `freqresp` uses Ts = 1.

Algorithms

For transfer functions or zero-pole-gain models, `freqresp` evaluates the numerator(s) and denominator(s) at the specified frequency points. For continuous-time state-space models (A, B, C, D), the frequency response is

`$\begin{array}{cc}D+C{\left(j\omega -A\right)}^{-1}B,& \omega =\end{array}{\omega }_{1},\dots ,{\omega }_{N}$`

For efficiency, A is reduced to upper Hessenberg form and the linear equation (jω − A)X = B is solved at each frequency point, taking advantage of the Hessenberg structure. The reduction to Hessenberg form provides a good compromise between efficiency and reliability. See [1] for more details on this technique.

Alternatives

Use `evalfr` to evaluate the frequency response at individual frequencies or small numbers of frequencies. `freqresp` is optimized for medium-to-large vectors of frequencies.

References

[1] Laub, A.J., "Efficient Multivariable Frequency Response Computations," IEEE® Transactions on Automatic Control, AC-26 (1981), pp. 407-408.

Version History

Introduced before R2006a