I'm studying signal processing, using MATLAB to plot filter responses. So far, I understand I can use the impulse response to apply a filter to a signal. For example, the impulse response of an $L$-length passband filter is:
$$h[n]=(2/L) \cos(\hat\omega_c n)$$
Where $0\leq n<L$ and $\hat\omega_c$ is the center frequency that defines the frequency location of the passband. I can use firfilt(h, xx)
to apply the filter above to a signal xx
. So far so good.
Now I would like to plot the frequency response of the system. For the system above, the study material states the frequency response is:
$$H(e^{j\hat\omega})=\sum\limits_{k=0}^{L-1} b_ke^{-j\hat\omega k}$$
According to the study material, the frequency response can be plotted in MATLAB by using ones(1, L) / L
for filter coefficients:
bb = ones(1, L) / L;
ww = -pi:(pi / 100):pi;
HH = freqz(bb, 1, ww);
subplot(2, 1, 1), plot(ww, abs(HH));
subplot(2, 1, 2), plot(ww, angle(HH));
Now I'm starting to get confused. Two questions so far:
- How are the coefficients
ones(1, L) / L
derived from the formula for $H(e^{j\hat\omega})$? Are they? - The frequency response is always centered at the origin. Can I introduce a different center frequency, so it matches with the impulse response?
Things get even more complicated when a second filter is introduced with a Hamming window. The impulse response is given as:
$$h[n]=0.54-0.46\cos(2\pi n/(L-1)))\cos(\hat\omega_c(n-(L-1)/2)$$
I know how to apply the impulse response to any given signal, but when asked to plot the frequency response, I'm assuming I need to convert the impulse response to a set of filter coefficients. In other words:
- How do I determine the frequency response based on the impulse response?