| Signal Processing Toolbox | Search  Help Desk |
| freqz | See Also |
Frequency response of digital filters.
Syntax
[h,w] = freqz(b,a,n) [h,f] = freqz(b,a,n,Fs) [h,w] = freqz(b,a,n,'whole') [h,f] = freqz(b,a,n,'whole',Fs) h = freqz(b,a,w) h = freqz(b,a,f,Fs) freqz(...)
Description
freqz returns the complex frequency response H(ej
) of a digital filter, given the (real or complex) numerator and denominator coefficients in vectors b and a.
[h,w] = freqz(b,a,n) returns the n-point complex frequency response of the digital filter
given the coefficient vectors b and a. freqz returns both h, the complex frequency response, and w, a vector containing the n frequency points in units of rads/sample. freqz evaluates the frequency response at n points equally spaced around the upper half of the unit circle, so w contains n points between 0 and
.
It is best, although not necessary, to choose a value for n that is an exact power of two, because this allows fast computation using an FFT algorithm. If you do not specify a value for n, it defaults to 512.
[h,f] = freqz(b,a,n,Fs)
specifies a positive sampling frequency Fs, in Hertz. The default for Fs is 1. It returns a vector f containing the actual frequency points between 0 and Fs/2 (the Nyquist frequency) at which it calculated the frequency response. f is of length n.
[h,w] = freqz(b,a,n,'whole')
uses n points around the whole unit circle, so w has range [0,2
).
[h,f] = freqz(b,a,n,'whole',Fs)
uses n points around the whole unit circle, so f has range [0,Fs).
h = freqz(b,a,w)
returns the frequency response at the frequencies in vector w (specified in rads/sample).
h = freqz(b,a,f,Fs)
returns the frequency response at the frequencies in vector f (specified in Hz).
freqz(...)
with no output arguments plots the magnitude and phase response versus frequency in the current figure window.
Examples
Plot the magnitude and phase response of an FIR filter.b = fir1(80,0.5,kaiser(81,8)); freqz(b,1);
![]()
Algorithm
freqz uses an FFT algorithm when argument n is present. It computes the frequency response as the ratio of the transformed numerator and denominator coefficients, padded with zeros to the desired length:
h = fft(b,n)./fft(a,n)If
n is not a power of two, the FFT algorithm is not as efficient and may cause long computation times.
When a frequency vector w or f is present, or if n is less than max(length(b),length(a)), freqz evaluates the polynomials at each frequency point using Horner's method of polynomial evaluation and then divides the numerator response by the denominator response.
See Also
abs |
Absolute value (magnitude). |
angle |
Phase angle. |
fft |
One-dimensional fast Fourier transform. |
filter |
Filter data with a recursive (IIR) or nonrecursive (FIR) filter. |
freqs |
Frequency response of analog filters. |
impz |
Impulse response of digital filters. |
invfreqz |
Discrete-time filter identification from frequency data. |
logspace |
Generate logarithmically spaced vectors (see the online MATLAB Function Reference). |