<< Chapter < Page | Chapter >> Page > |
Type | $()$ | $A()$ |
---|---|---|
I | $-(M)$ | $h(M)+2\sum_{n=0}^{M-1} h(n)\cos ((M-n))$ |
II | $-(M)$ | $2\sum_{n=0}^{\frac{N}{2}-1} h(n)\cos ((M-n))$ |
III | $-(M)+\frac{\pi}{2}$ | $2\sum_{n=0}^{M-1} h(n)\sin ((M-n))$ |
IV | $-(M)+\frac{\pi}{2}$ | $2\sum_{n=0}^{\frac{N}{2}-1} h(n)\sin ((M-n))$ |
To analyze or design linear-phase FIR filters, we need to know the characteristics of the amplitude response $A()$ .
Type | Properties | |
---|---|---|
I | $A()$ is even about $=0$ | $A()=A(-)$ |
$A()$ is even about $=\pi $ | $A(\pi +)=A(\pi -)$ | |
$A()$ is periodic with $2\pi $ | $A(+2\pi )=A()$ | |
II | $A()$ is even about $=0$ | $A()=A(-)$ |
$A()$ is odd about $=\pi $ | $A(\pi +)=-A(\pi -)$ | |
$A()$ is periodic with $4\pi $ | $A(+4\pi )=A()$ | |
III | $A()$ is odd about $=0$ | $A()=-A(-)$ |
$A()$ is odd about $=\pi $ | $A(\pi +)=-A(\pi -)$ | |
$A()$ is periodic with $2\pi $ | $A(+2\pi )=A()$ | |
IV | $A()$ is odd about $=0$ | $A()=-A(-)$ |
$A()$ is even about $=\pi $ | $A(\pi +)=A(\pi -)$ | |
$A()$ is periodic with $4\pi $ | $A(+4\pi )=A()$ |
The frequency response ${H}^{f}()$ of an FIR filter can be evaluated at $L$ equally spaced frequencies between 0 and $\pi $ using the DFT. Consider a causal FIR filter with an impulse response $h(n)$ of length- $N$ , with $N\le L$ . Samples of the frequency response of the filter can be written as $$H(\frac{2\pi}{L}k)=\sum_{n=0}^{N-1} h(n)e^{-i\frac{2\pi}{L}nk}$$ Define the $L$ -point signal $\{g(n)\colon 0\le n\le L-1\}$ as $$g(n)=\begin{cases}h(n) & \text{if $0\le n\le N-1$}\\ 0 & \text{if $N\le n\le L-1$}\end{cases}$$ Then $$H(\frac{2\pi}{L}k)=G(k)={\mathrm{DFT}}_{L}(g(n))$$ where $G(k)$ is the $L$ -point DFT of $g(n)$ .
Suppose the FIR filter $h(n)$ is either a Type I or a Type II FIR filter. Then we have from above $${H}^{f}()=A()e^{-iM}$$ or $$A()={H}^{f}()e^{iM}$$ Samples of the real-valued amplitude $A()$ can be obtained from samples of the function ${H}^{f}()$ as: $$A(\frac{2\pi}{L}k)=H(\frac{2\pi}{L}k)e^{iM\frac{2\pi}{L}k}=G(k){W}_{L}^{Mk}$$ Therefore, the samples of the real-valued amplitude function can be obtained by zero-padding $h(n)$ , taking the DFT, and multiplying by the complex exponential. This can be written as:
For Type III and Type IV FIR filters, we have $${H}^{f}()=ie^{-iM}A()$$ or $$A()=-i{H}^{f}()e^{iM}$$ Therefore, samples of the real-valued amplitude $A()$ can be obtained from samples of the function ${H}^{f}()$ as: $$A(\frac{2\pi}{L}k)=-iH(\frac{2\pi}{L}k)e^{iM\frac{2\pi}{L}k}=-iG(k){W}_{L}^{Mk}$$ Therefore, the samples of the real-valued amplitude function can be obtained by zero-padding $h(n)$ , taking the DFT, and multiplying by the complex exponential.
In this example, the filter is a Type I FIR filter of length 7. An accurate plot of $A()$ can be obtained with zero padding.
The following Matlab code fragment for the plot of $A()$ for a Type I FIR filter.
h = [3 4 5 6 5 4 3]/30;N = 7;
M = (N-1)/2;L = 512;
H = fft([h zeros(1,L-N)]);
k = 0:L-1;W = exp(j*2*pi/L);
A = H .* W.^(M*k);A = real(A);
figure(1)w = [0:L-1]*2*pi/(L-1);subplot(2,1,1)
plot(w/pi,abs(H))ylabel('|H(\omega)| = |A(\omega)|')
xlabel('\omega/\pi')subplot(2,1,2)
plot(w/pi,A)ylabel('A(\omega)')
xlabel('\omega/\pi')print -deps type1
The command
A = real(A)
removes the
imaginary part which is equal to zero to within computerprecision. Without this command, Matlab takes
A
to be a complex vector and the
following plot command will not be right.
Observe the symmetry of $A()$ due to $h(n)$ being real-valued. Because of this symmetry, $A()$ is usually plotted for $0\le \le \pi $ only.
The following Matlab code fragment produces a plot of $A()$ for a Type II FIR filter.
h = [3 5 6 7 7 6 5 3]/42;N = 8;
M = (N-1)/2;L = 512;
H = fft([h zeros(1,L-N)]);
k = 0:L-1;W = exp(j*2*pi/L);
A = H .* W.^(M*k);A = real(A);
figure(1)w = [0:L-1]*2*pi/(L-1);subplot(2,1,1)
plot(w/pi,abs(H))ylabel('|H(\omega)| = |A(\omega)|')
xlabel('\omega/\pi')subplot(2,1,2)
plot(w/pi,A)ylabel('A(\omega)')
xlabel('\omega/\pi')print -deps type2
The imaginary part of the amplitude is zero. Notice that $A(\pi )=0$ . In fact this will always be the case for a Type II FIR filter.
An exercise for the student: Describe how to obtain samples of $A()$ for Type III and Type IV FIR filters. Modify the Matlab code above for these types. Do you notice that $A()=0$ always for special values of $$ ?
Notification Switch
Would you like to follow the 'Intro to digital signal processing' conversation and receive update notifications?