# Filter Design Using Rectangular Window And Kaiser Window Marketing Essay

**Published:** **Last Edited:**

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

## ABSTRACT

This project deals with Design of FIR filters using two types of windowing methods(Rectangular window and the Kaiser window) and the comparison of the results obtained.

The FIR filter is designed using the windows in Mathworks - MATLAB software using the MATLAB coding and the results are being explained for each window separately and the result for comparing both the windows is also shown. In rectangular window assumed values of frequencies and sampling frequency is taken. In the Kaiser window the frequency values taken are assumed and result for different beta values are taken.

The comparison of windowing methods Kaiser window and rectangular window result is shown at the last for two different beta values, as the beta function in Kaiser window plays a major role which attenuates the gain. The resultant graph of the comparison shows that the Kaiser window is more reliable and result in high gain than the rectangular window.

## 2. INTRODUCTION

In signal processing technique a filter is a component which eliminates unwanted elements of the signal (noise or any disturbances) and extracts the useful or the desired parts of the signal by filtering the original signal. When a noise signal is given as an input to the filter the filter removes the noise and the resultant filtered signal is obtained as the output to the noise signal based on the specifications of the design of the filter. Filters that are been used in Digital Signal Processing (DSP) have been a great zeal to work on for the engineers in recent years, Especially Digital filters nowadays have been used more relevantly and more often than the counterpart analog filter. Filters are the one, simply they allow a range of frequencies to pass and stop anything outside the range.

Based on the classifications the filter structures are classified into two types. They are

IIR (INFINITE IMPULSE RESPONSE).

FIR(FINITE IMPULSE RESPONSE )

## 2.1. IIR FILTERS:

The Infinite Impulse Response Filters as the name says, have an impulse response functions which is non zero over an infinite length of time. In the IIR Filters the present output obtained depends not only on the present input, but also on the past input and past output obtained. These filters may be implemented either as analog or digital filters. To implement a digital filter, analog filter is designed and converted to digital filter by using Bi-linear transform or Impulse invariance techniques.

The IIR has different types of filters, They are

Butterworth Filters,

Chebyshev Filters TYPE -1,

Chebyshev TYPE- II (or) Inverse Chebyshev Filters,

Elliptic filter (or) Cauer Filters,

Bessel Filters.

C:\Users\KALYAN\Desktop\DSP\iir filters\800px-IIRFilter2.svg.png

## 2.1.1. Figure: Block diagram of a simple IIR filter [1]

## 2.2. FIR FILTERS:

As the name says the filters have a finite impulse response function which has finite length of time. The output y(n) of the filter is simply the convolution of impulse response and the input signal x(n) . In simply terms the co-efficient of a filter are the impulse response. The equation is given by

C:\Users\Deepu\Desktop\Capture.PNG

## Fig 2.2.1: Block Diagram showing FIR Filter. [1]

To design a filter there are some basic requirements which should be taken into consideration, they are

Frequency response,

Impulse response ,

Causality,

Stability,

Complexity should be low ,

Hardware implementation ,

Software implementation.

## 2.2.1. Properties of FIR filter:

1) Stability: These Filters are Stable i.e. Bounded Input Bounded Output (BIBO) because the poles located at the origin and are within the unit circle.

2)Feedback: There is no feedback for this kind of filters which in turn means rounding errors are not compounded by summed iterations, the error repeats in each of the iteration and by this implementation seems simple.

3) Linear Phase: This co-efficient sequence has to be made symmetric and the property seems to have an important role in phase - sensitivity applications.

## 2.2.2. Advantages of FIR Filter:

Simple to design, delay the input signal (Linear-phase) without altering the phase.

Calculations are simple and need single instruction for looping.

Multi-rate Applications. Where you see interpolation (increase sampling rate) and decimation (sampling rate decreased) or both which in turn related to computational efficiency.

FIR Filters have desirable properties i.e. numeric properties. Finite-precision filters are implemented in DSP filters i.e. limited no. of bits.

Fractional arithmetic implementation can be seen by this type of the filters.

## 2.2.3. Disadvantages of FIR Filter:

As we know every filter has some advantages, in the same manner we have to see the other side of the filter i.e. disadvantages of the filter and they are

It needs more memory i.e. more calculation to achieve desired response characteristics.

You cannot see very sharp edges in FIR filters (brick wall shape).

To meet the specified frequency, no. states needs to be more compared to IIR Filters.

## 3. TYPES OF WINDOW TECHNIQUES:

The Digital filter designing using this windowing method is more convenient, fast and robust and there are more windows designed and implemented and they are

Rectangular Window,

Bartlett (Triangular) Window,

Blackman Window,

Hamming Window,

Hanning Window,

Kaiser Window,

Lanczos Window,

Tukey Window.

As far as our project is concerned we have mainly concentrated on the two types of windowing methods. They are Rectangular window method and Kaiser window method.

Above all of those windows which are designed and implemented, we go further to explain in detail only two types of window showing the algorithm and writing the Matlab code for that and show you some relevant graphs and try to compare both with their frequency response characteristics.

## 3.1. RECTANGULAR WINDOW:

We start with Hd(w) -desired frequency response and by this we come up with hd(n) .the relation between by Hd(w) and the hd(n) by the Fourier transform

Where the inverse of hd(n) is given by the equation

Description: http://www.bme.unc.edu/%7Eclucas/ch9/Image65.gif

From the above from we come to determine the unit impulse response by the integral.

Truncation of the desired response hd(n) to a length (M-1) i.e. multiplying hd(n) by a "Rectangular window" and is given by

Thus the FIR filter's unit impulse response i.e. the Fourier transform of the rectangular window becomes

And the magnitude and phase response would be

## 3.2. KAISER WINDOW:

In practice Kaiser Window is very useful and it's the zero-th order, first kind of Bessel Function.

Definition:

And the Fourier transform for this kind of window is

## 4. FILTER DESIGN:

Designing a filter means the co-efficient has some specific characteristics. To find these co-efficient for frequency characteristics there are different methods.

Window design method

Parks-McClellan method

Weight least squares design

Frequency sampling method

Equi ripple FIR filters.

## 4.1. WINDOW DESIGN METHOD:

A window function is a mathematical function whose value is zero outside the given interval of time, which describes the graphical representation. The window function does not be zero outside the interval as the product of the window is multiplied by argument of square integrable and then gradually decreases to zero. A window function is also known as tapering function. the window function is used in different applications such as beam forming, spectral analysis, filter design .etc.,

## 5. Deciphering the MATLAB code:

Inbuilt Functions used:

rectwin(N = returns the N-point rectangular window. Boxcar ( ) can also be used for rectangular window representation.

figure(n)= creates a new figure and n denotes the figure number.

fir1(N,Wn,WIN)= designs a N-th order FIR filter.

freqz= function calculates the suitable complex frequency response of the filter.

ceil(N/D )=gives the rounded value of the N/D.

abs(h)= returns the Absolute value of element h.

plot(x,y )=this function plots the x by y graph.

Subplot(m,n,p)= this function Create axes in tiled positions and m represents number of rows, n represents number of columns and p represents the axis of the plot.

title(n)=this function is used to add title to the current graph.

xlabel( )= adds label beside the x- axis.

ylabel( )= adds label beside the y- axis.

kaiser(n,beta)= returns betavalue for the n-point in Kaiser window.

Generally the beta value is considered to be 0.5.

## 6. MATLAB CODE FOR RECTANGULAR WINDOW:

we have assumed the following values

Ripple Pass band = 0.04,

Stop band Attenuation = 0.05,

Pass band Frequency =2000Hz,

Stop band Frequency = 3000Hz,

Cut off Frequency=9000Hz.

## MATLAB CODE:

clc;

clear all;

close all;

passripple=.04;

stopripple=.05;

passfreq=2000;

stopfreq=3000;

freq= 9000;

wp=2*passfreq/freq;

ws=2*stopfreq/freq;

p=passripple*stopripple;

q=stopfreq-passfreq;

r=q*freq;

N=-20*log10(sqrt(p))-13;

D=14.6*r;

n=ceil(N/D);

n1=n+1;

if(rem(n,2)~=0)

n1=n;

n=n-1;

end

y=rectwin(n1);

b=fir1(n,wp,y,'low'); %low pass filter

[h,o]=freqz(b,1,256);

m=20*log10(abs(h));

figure(1)

subplot(2,2,1);

plot(o/pi,m);

title('Low pass filter');

ylabel('gain in db');

xlabel('(a) normalised frequency');

b=fir1(n,wp,'high',y); %high pass filter

[h,o]=freqz(b,1,256);

m=20*log10(abs(h));

subplot(2,2,2);

plot(o/pi,m);

title('high pass filter');

ylabel( 'gain in db');

xlabel('(b) normalised frequency');

wn=[wp,ws]; %band pass filter

b=fir1(n,wn,y);

[h,o]=freqz(b,1,256);

m=20*log10(abs(h));

subplot(2,2,3);

plot(o/pi,m);

title('Band pass filter');

ylabel('gain in db');

xlabel('(c)normalised frequency');

b=fir1(n,wn,'stop',y); %band stop filter

[h,o]=freqz(b,1,256);

m=20*log10(abs(h));

subplot(2,2,4);

plot(o/pi,m);

title('band stop filter');

ylabel('gain in db');

xlabel('(d) normalised frequency');

## OUTPUT:

## 6.1. FIGURE: OUTPUT OF RECTANGULAR WINDOW

## 7. MATLAB CODE FOR KAISER WINDOW:

Ripple Pass band = 0.04,

Stop band Attenuation = 0.05,

Pass band Frequency =2000Hz,

Stop band Frequency = 3000Hz,

Cut off Frequency=9000Hz,

Beta=2, 4.

## MATLAB CODE:

clc;

clear all;

close all;

passripple=0.04; %pass band ripple

stopripple=0.05; %stop band ripple

passfreq=2000; %pass band ripple

stopfreq=3000; %pass band ripple

freq=9000; %sampling freq

wp=2*passfreq/freq;

ws=2*stopfreq/freq;

s=passripple*stopripple;

r=stopfreq-passfreq;

p=r/freq;

N=-20*log10(sqrt(s))-13;

D=14.6*p;

n=ceil(N/D);

n1=n+1;

if(rem(n,2)~=0)

n1=n;

n=n-1;

end

beta=2;

for beta=2:2:4

y=kaiser(n1,beta);

b=fir1(n,wp,y); %low pass filter

[h,o]=freqz(b,1,256);

m=20*log10(abs(h));

figure(beta)

subplot(2,2,1);

plot(o/pi,m,'b');

title('Low pass filter');

ylabel('gain in db');

xlabel('(a) normalised frequency');

b=fir1(n,wp,y); %high pass filter

[h,o]=freqz(b,1,256);

m=20*log10(abs(h));

subplot(2,2,2);

plot(o/pi,m,'b');

title('high pass filter');

ylabel( 'gain in db');

xlabel('(b) normalised frequency');

wn=[wp,ws]; %band pass filter

b=fir1(n,wn,y);

[h,o]=freqz(b,1,256);

m=20*log10(abs(h));

subplot(2,2,3);

plot(o/pi,m,'b');

title('Band pass filter');

ylabel('gain in db');

xlabel('(c)normalised frequency');

b=fir1(n,wn,'stop',y); %band stop filter

[h,o]=freqz(b,1,256);

m=20*log10(abs(h));

subplot(2,2,4);

plot(o/pi,m,'b');

title('band stop filter');

ylabel('gain in db');

xlabel('(d) normalised frequency');

end

## OUTPUT:

## 7.1. FIGURE: When beta value is 2.

## 7.2. FIGURE: When beta value is 4

## 8. MATLAB CODE FOR COMPARISION OF WINDOW METHODS

clc;

clear all;

close all;

passripple=0.04; %pass band ripple

stopripple=0.05; %stop band ripple

passfreq=2000; %pass band ripple

stopfreq=3000; %pass band ripple

freq=9000; %sampling freq

wp=2*passfreq/freq;

ws=2*stopfreq/freq;

s=passripple*stopripple;

r=stopfreq-passfreq;

p=r/freq;

num=-20*log10(sqrt(s))-13;

dem=14.6*p;

n=ceil(num/dem);

n1=n+1;

if(rem(n,2)~=0)

n1=n;

n=n-1;

end

beta=4;

y=kaiser(n1,beta);

b=fir1(n,wp,y); %low pass filter

[h,o]=freqz(b,1,256);

m=20*log10(abs(h));

figure(2)

subplot(2,2,1);

plot(o/pi,m,'b');

title('Low pass filter');

ylabel('gain in db');

xlabel('(a) normalised frequency');

b=fir1(n,wp,y); %high pass filter

[h,o]=freqz(b,1,256);

m=20*log10(abs(h));

subplot(2,2,2);

plot(o/pi,m,'b');

title('high pass filter');

ylabel( 'gain in db');

xlabel('(b) normalised frequency');

wn=[wp,ws]; %band pass filter

b=fir1(n,wn,y);

[h,o]=freqz(b,1,256);

m=20*log10(abs(h));

subplot(2,2,3);

plot(o/pi,m,'b');

title('Band pass filter');

ylabel('gain in db');

xlabel('(c)normalised frequency');

b=fir1(n,wn,'stop',y); %band stop filter

[h,o]=freqz(b,1,256);

m=20*log10(abs(h));

subplot(2,2,4);

plot(o/pi,m,'b');

title('band stop filter');

ylabel('gain in db');

xlabel('(d) normalised frequency');

hold on

ys=rectwin(n1);

b=fir1(n,wp,ys); %low pass filter

[h,o]=freqz(b,1,256);

m=20*log10(abs(h));

figure(1)

subplot(2,2,1);

plot(o/pi,m,'r');

title('Low pass filter');

ylabel('gain in db');

xlabel('(a) normalised frequency');

b=fir1(n,wp,ys); %high pass filter

[h,o]=freqz(b,1,256);

m=20*log10(abs(h));

subplot(2,2,2);

plot(o/pi,m,'r');

title('high pass filter');

ylabel( 'gain in db');

xlabel('(b) normalised frequency');

wn=[wp,ws]; %band pass filter

b=fir1(n,wn,ys);

[h,o]=freqz(b,1,256);

m=20*log10(abs(h));

subplot(2,2,3);

plot(o/pi,m,'r');

title('Band pass filter');

ylabel('gain in db');

xlabel('(c)normalised frequency');

b=fir1(n,wn,'stop',ys); %band stop filter

[h,o]=freqz(b,1,256);

m=20*log10(abs(h));

subplot(2,2,4);

plot(o/pi,m,'r');

title('band stop filter');

ylabel('gain in db');

xlabel('(d) normalised frequency');

## 8.1. OUTPUT:

## FIGURE: OUTPUT FOR COMPARISION OF BOTH THE WINDOWS

Blue color- Kaiser Window, Red color-Rectangular window

## 9. CONCLUSION

FIR Filters using Windowing is a method where we see the significant changes in the frequency characteristics.

Rectangular Window plays a significant role in determine the resulting frequency response which obtained by truncating hd(n) to length M. The convolution of Hd(w) with W(w). As we go on increasing the M, W(w) becomes narrower, and the smoothing provided by W(w)is reduced. On the other hand, the large sidelobes of W(w) result in some undesirable ringing effects in the FIR filter frequency response H(w), and also in relatively larger sidelobes in H(w).These undesirable effects are best alleviated by the use of windows that do not contain abrupt discontinuities in their time-domain characteristics, and have correspondingly low sidelobes in their frequency - domain characteristics.

Kaiser Window has frequency response characteristics where the response is basically revolved around the value of Beta (Î²), M and Î² trade off sidelobe amplitude and mainlobe width. Where M is the Order of the signal. Î² controls width and tapering off both (i.e., as b increases, width gets large but sidelobe amplitudes get smaller.) M does not change ripple error (to achieve Delta) this is determined by the sidelobe amplitude (determined by Î², or type of window).

The comparison of both the window techniques is shown in the graph. The gain in the Kaiser window is more than the rectangular window.