Fir Filter Design Using Matlab
Fir Filter Design Using Matlab
Fir Filter Design Using Matlab
A finite impulse response (FIR) filter is a type of a signal processing filter whose impulse response (or response to any finite length input) is of finite duration, because it settles to zero in finite time. The impulse response of an Nth-order discrete-time FIR filter lasts for N+1 samples, and then dies to zero. FIR filters can be discrete-time or continuous-time, and digital or analog.
Definition:
The output y of a linear time invariant system is determined by convolving its input signal x with its impulse response b. For a discrete-time FIR filter, the output is a weighted sum of the current and a finite number of previous values of the input. The operation is described by the following equation, which defines the output sequence y[n] in terms of its input sequence x[n]:
Where:
x[n] is the input signal, y[n] is the output signal, bi are the filter coefficients, also known as tap weights, that make up the impulse response, N is the filter order; an Nth-order filter has (N + 1) terms on the right-hand side. The x[n i] in these terms are commonly referred to as taps, based on the structure of a tapped delay line that in many implementations or block diagrams provides the delayed inputs to the multiplication operations. One may speak of a "5th order/6-tap filter", for instance.
Figure: A discrete-time FIR filter of order N. The top part is an N-stage delay line with N+1 taps. Each unit delay is a z-1 operator in Z-transform notation. PROPERTIES: An FIR filter has a number of useful properties which sometimes make it preferable to an infinite impulse response (IIR) filter. FIR filters:
Require no feedback. This means that any rounding errors are not compounded by summed iterations. The same relative error occurs in each calculation. This also makes implementation simpler. Are inherently stable. This is due to the fact that, because there is no required feedback, all the poles are located at the origin and thus are located within the unit circle (the required condition for stability in a Z transformed system). They can easily be designed to be linear phase by making the coefficient sequence symmetric; linear phase, or phase change proportional to frequency, corresponds to equal delay at all frequencies. This property is sometimes desired for phase-sensitive applications, for example data communications, crossover filters, and mastering.
The main disadvantage of FIR filters is that considerably more computation power in a general purpose processor is required compared to an IIR filter with similar sharpness or selectivity, especially when low frequency (relative to the sample rate) cutoffs are needed. However many digital signal processors provide specialized hardware features to make FIR filters approximately as efficient as IIR for many applications. WINDOWING: Windowing of a simple waveform, like cos t causes its Fourier transform to develop non-zero values (commonly called spectral leakage) at frequencies other than . The leakage tends to be worst (highest) near and least at frequencies farthest from .
Hamming Window: Create a 64-point Hamming window and display the result in WVTool: N=64; wvtool(hamming(N))
Time d omain 40 1 20
0.8
Amp litude
0.6
-20
-40
0.4 -60
0.2 -80
-10 0
0.2 0.4 0.6 0.8 Norma liz ed Fre quen c y ( vT rad/s ample)
Case 1:
N=16
W=[0.4 0.6] B=fir1(N,W,'DC-1') %Design FIR Filter using default (Hamming window). freqz(B,A)
0.1
0.2
0.3 0.4 0.5 0.6 0.7 0.8 Norm aliz ed F requenc y ( vT rad/s am ple)
0.9
0 P ha s e (degrees )
-500
-1000
-1500
0.1
0.2
0.3 0.4 0.5 0.6 0.7 0.8 Norm aliz ed F requenc y ( vT rad/s am ple)
0.9
Case 2: N=32.
-20
-40
0.1
0.2
0.3 0.4 0.5 0.6 0.7 0.8 Norm aliz ed F requenc y ( vT rad/s am ple)
0.9
0 P ha s e (degrees )
-1000
-2000
-3000
0.1
0.2
0.3 0.4 0.5 0.6 0.7 0.8 Norm aliz ed F requenc y ( vT rad/s am ple)
0.9
Case 3: N=34
0.1
0.2
0.3 0.4 0.5 0.6 0.7 0.8 N orm aliz ed F requenc y ( vT rad/s am ple)
0.9
0.1
0.2
0.3 0.4 0.5 0.6 0.7 0.8 N orm aliz ed F requenc y ( vT rad/s am ple)
0.9
Case4: N=35
50 Magnitude (dB)
-50
-100
0.1
0.2
0.3 0.4 0.5 0.6 0.7 0.8 N orm aliz ed F requenc y ( vT rad/s am ple)
0.9
0 Phase (degrees)
-1000
-2000
-3000
0.1
0.2
0.3 0.4 0.5 0.6 0.7 0.8 N orm aliz ed F requenc y ( vT rad/s am ple)
0.9
Case 5:N=48
50 Magnitude (dB)
-50
-100
0.1
0.2
0.3 0.4 0.5 0.6 0.7 0.8 N orm aliz ed F requenc y ( vT rad/s am ple)
0.9
0.1
0.2
0.3 0.4 0.5 0.6 0.7 0.8 N orm aliz ed F requenc y ( vT rad/s am ple)
0.9