Signal Processing Toolbox Help Desk

freqz

Purpose

Frequency response of digital filters.

Syntax

Description

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 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. 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. 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 2 , or from 0 to Fs).

h = freqz(b,a,w) returns the frequency response at the frequencies in vector w. These frequencies must be between 0 and 2.

h = 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.

Example

Plot the magnitude and phase response of a Butterworth filter:

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:

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 MATLAB Function Reference).



[ Previous | Help Desk | Next ]