Digital Signal Processing Reference
In-Depth Information
myfilt = [1, 1, 1, 1, 1];
y = conv(imp, myfilt);
Y = fft(y);
maxY = max(abs(Y));
half = 1:ceil(length(y)/2);
subplot(2,1,1);
plot(half, abs(Y(half))/maxY, b);
title(FMR for filter coeffs [1, 1, 1, 1, 1]);
axis tight;
We can compare this to the eect of another lter, one where the lter coecients
more gradually approach 1, then gradually fall.
myfilt2 = [1/3, 2/3, 1, 2/3, 1/3];
y2 = conv(imp, myfilt2);
Y2 = fft(y2);
maxY2 = max(abs(Y2));
subplot(2,1,2);
plot(half, abs(Y2(half))/maxY2, b);
title(FMR for filter coeffs [1/3, 2/3, 1, 2/3, 1/3]);
axis tight;
From the graph, shown in Figure 10.6, we see that both sets of lter coecients
produce a lowpass lter. However, the top graph shows a sizeable side lobe where the
frequency response becomes larger and then smaller. While the frequency response
is very small around index 200, we see that it becomes much larger after this point.
On the other graph, we see the frequency response approach zero a bit more slowly
(we say it has a wider main lobe). We also see that it has a much smaller side
lobe. These graphs demonstrate the eect of a window; in fact, the second lter's
coecients were chosen from the simple \triangle" window. In other words, the rst
set of lter coecients were \windowed" to make the second set.
The command below returns the 5-value \triangle" window function. Note that
the window function is part of the optional Signal Processing toolbox in MATLAB.
>> w = window(@triang, 5)
w =
0.3333
0.6667
Search WWH ::




Custom Search