Main Content

freqresp

Evaluate system response over a grid of frequencies

Description

Use freqresp to evaluate the system response over a grid of frequencies. To obtain the magnitude and phase data as well as plots of the frequency response, use bode.

example

[H,wout] = freqresp(sys) returns the frequency response of the dynamic system model sys at frequencies wout. freqresp automatically determines the frequencies based on the dynamics of sys. For more information about frequency response, see Frequency Response.

example

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.

example

[H,wout,covH] = freqresp(sys,___) also returns the covariance covH of the frequency response. Use this syntax only when sys is an identified model of one of the types listed in Identified LTI Models (Control System Toolbox).

Examples

collapse all

For this example, consider the following SISO state-space model:

A=[-1.5-210]B=[0.50]C=[01]D=0SISO State-Space Model

Create the SISO state-space model defined by the following state-space matrices:

A = [-1.5,-2;1,0];
B = [0.5;0];
C = [0,1];
D = 0;
sys = ss(A,B,C,D);

Compute the frequency response of the system.

[H,wout] = freqresp(sys);
size(H)
ans = 1×3

     1     1    56

H contains the frequency response at 56 frequencies that are automatically chosen based on the dynamics of sys.

size(wout)
ans = 1×2

    56     1

wout contains the corresponding 56 frequencies.

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

sys=[01s+1s-1s+21]

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=[01s+1s-1s+21]

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.

Input Arguments

collapse all

Dynamic system, specified as a SISO or MIMO dynamic system model or array of dynamic system models. Dynamic systems that you can use include:

  • LTI models such as ss (Control System Toolbox), tf (Control System Toolbox), and zpk (Control System Toolbox) models.

  • Sparse state-space models, such as sparss (Control System Toolbox) or mechss (Control System Toolbox) models.

  • Generalized or uncertain state-space models such as genss (Control System Toolbox) or uss (Robust Control Toolbox) models. (Using uncertain models requires Robust Control Toolbox™ software.)

    • For tunable control design blocks, the function evaluates the model at its current value to evaluate the frequency response.

    • For uncertain control design blocks, the function evaluates the frequency response at the nominal value and random samples of the model.

  • Identified state-space models, such as idss models.

For a complete list of models, see Dynamic System Models.

Frequencies at which to evaluate system response, specified as a vector. Specify frequencies in units of rad/TimeUnit, where TimeUnit is the time units specified in the TimeUnit property of sys. You can specify the frequencies directly as real values, or in terms of the Laplace variables s and z.

  • To obtain the system response at specified frequencies, use real values in w.

  • To obtain the system response at specified points in the s or z plane, use complex values. freqresp interprets complex values as follows:

    • For continuous-time sys, the function interprets w as w(k) = s(k) = j*freq(k), where freq(k) are the frequencies corresponding to each s value.

    • For discrete-time sys, the function interprets w as w(k) = z(k) = exp(j*freq(k)*Ts), where freq(k) are the frequencies and Ts is the sample time of sys.

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'

Output Arguments

collapse all

Frequency response values, returned as an array. The dimensions of H depend on the dimensions of sys.

  • If sys is a SISO model, then H is an array of dimensions 1-by-1-by-Nw, where Nw is the number of frequency points (length(w) or length(wout).

  • If sys is a MIMO model with Ny outputs and Nu inputs, H is an Ny-by-Nu-by-Nw, Thus, H(:,:,k) is the response of all I/O channels at the kth frequency, and H(a,b,:) is the response from input b to output a.

  • If sys is a model array with array dimensions [S1 ... Sn, containing models with I/O dimensions [Ny Nu], then H is an array with dimensions Ny-by-Nu-by-Nw-by-S1-by-...-by-Sn. For instance, the response at all computed frequencies of the first output to the second input of the third system in the array is H(1,2,:,3).

For frequency response data models (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.

Output frequencies corresponding to the frequency response H, returned as a vector. When 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

Covariance of the frequency response, returned as a 5D array. For instance, 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.

More About

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(jω)=D+C(jωIA)1B

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=ejωTs. 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

D+C(jωA)1B,ω=ω1,,ω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. For more details on this technique, see [1] (Control System Toolbox).

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

See Also

| | | (Control System Toolbox) | (Control System Toolbox) | |