Signal Processing Toolbox | Help Desk |
freqz
Frequency response of digital filters.
[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(b,a)
freqz
returns the complex frequency response H(ejw) of a digital filter, given the 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 filterb
and a
. freqz
returns both h
, the complex frequency response, and w
, a vector containing the n
frequency points. 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 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. It returns a vector f
containing the actual frequency points between 0 and Fs/2
at which it calculated the frequency response. f
is of length n
.
[h,w] = freqz(b,a,n,'whole')
and
[h,f] = freqz(b,a,n,'whole',Fs)
use n
points around the whole unit circle (from 0 to 2Fs
).
h = freqz(b,a,w)
returns the frequency response at the frequencies in vector w
. These frequencies must be between 0 and 2h = freqz(b,a,f,Fs)
returns the frequency response at the frequencies in vector f
,
where the elements of f
are between 0 and Fs
.
freqz
with no output arguments plots the magnitude and phase response versus frequency in the current figure window.
freqz
works for both real and complex input systems.
Plot the magnitude and phase response of a Butterworth filter:
[b,a] = butter(5,0.2); freqz(b,a,128)
![]()
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.
Filter data with a recursive (IIR) or nonrecursive (FIR) filter. |
|
Generate logarithmically spaced vectors (see MATLAB Function Reference). |