Documentation Center

  • Trial Software
  • Product Updates

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 the string 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

String specifying the units of the frequencies in the input frequency vector w. Units can take 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 ith input to the jth 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

Frequency Response

Compute the frequency response of the 2-input, 2-output system

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

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

Response on Specified Frequency Grid

Compute the frequency response of the 2-input, 2-output system

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

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

w = logspace(1,2,200);

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

Frequency Response and Associated Covariance

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

load iddata1 z1
model = procest(z1, 'P2UZ');
w = 4.26;
[H,~,covH] = freqresp(model, w)

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.

More About

expand 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

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

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.

References

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

See Also

| | | | | | |

Was this topic helpful?