freqz uses an FFT-based algorithm to calculate the z-transform
frequency response of a digital filter. Specifically, the statement
[h,w] = freqz(b,a,p)
returns the p-point complex frequency response, H(ejω), of the digital filter.
In its simplest form,
freqz accepts the filter
and an integer
p specifying the number of points
at which to calculate the frequency response.
the complex frequency response in vector
the actual frequency points in vector
w in rad/s.
freqz can accept other parameters, such as
a sampling frequency or a vector of
arbitrary frequency points. The example below finds the 256-point
frequency response for a 12th-order Chebyshev Type I filter. The call
freqz specifies a sampling frequency
[b,a] = cheby1(12,0.5,200/500); [h,f] = freqz(b,a,256,1000);
Because the parameter list includes a sampling frequency,
f that contains the 256 frequency points
between 0 and
fs/2 used in the frequency response
Note This toolbox uses the convention that unit frequency is the Nyquist frequency, defined as half the sampling frequency. The cutoff frequency parameter for all basic filter design functions is normalized by the Nyquist frequency. For a system with a 1000 Hz sampling frequency, for example, 300 Hz is 300/500 = 0.6. To convert normalized frequency to angular frequency around the unit circle, multiply by π. To convert normalized frequency back to hertz, multiply by half the sample frequency.
If you call
freqz with no output arguments,
it plots both magnitude versus frequency and phase versus frequency.
For example, a ninth-order Butterworth lowpass filter with a cutoff
frequency of 400 Hz, based on a 2000 Hz sampling frequency, is
[b,a] = butter(9,400/1000);
freqz can also accept a vector of arbitrary
frequency points for use in the frequency response calculation. For
w = linspace(0,pi); h = freqz(b,a,w);
calculates the complex frequency response at the frequency
w for the filter defined
The frequency points can range from 0 to 2π. To specify a frequency
vector that ranges from zero to your sampling frequency, include both
the frequency vector and the sampling frequency value in the parameter
freqs evaluates frequency
response for an analog filter defined by two input coefficient vectors,
a. Its operation is similar to that
freqz; you can specify a number of frequency
points to use, supply a vector of arbitrary frequency points, and
plot the magnitude and phase response of the filter.