Documentation |
Frequency response over grid
[H,wout]
= freqresp(sys)
H = freqresp(sys,w)
H = freqresp(sys,w,units)
[H,wout,covH]
= freqresp(idsys,...)
[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.
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:
Default: 'rad/TimeUnit' |
idsys |
Any identified model. |
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. |
Compute the frequency response of the 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]; [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.
Compute the frequency response of the 2-input, 2-output system
$$sys=\left[\begin{array}{cc}0& \frac{1}{s+1}\\ \frac{s-1}{s+2}& 1\end{array}\right]$$
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).
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)
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.