Here is a sample program to compute and plot the magnitude response:
main.m282 chars14 lines
This program creates a lowpass FIR filter with 51 taps and a cutoff frequency of 0.5pi. It then computes the frequency response of the filter over the range of frequencies from -pi to pi, in increments of 0.01pi. Finally, it plots the magnitude response in dB, with frequency normalized to the range of -1 to 1.
Note that the freqz
function returns the complex frequency response of a filter, but we take only the magnitude of this response in order to plot the frequency response.
gistlibby LogSnag