0% found this document useful (0 votes)
30 views105 pages

DSP Lab Manual New

Uploaded by

rajeshsaritha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views105 pages

DSP Lab Manual New

Uploaded by

rajeshsaritha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 105

Mother Teresa Institute of Science and Technology, Sathupally

S.NO. NAME OF EXPERIMENT PAGE NO.

1 GENERATION OF SINUSOIDAL WAVE FORM 03

2 DISCRETE FOURIER TRANSFORM 09

3 GENERATION OF DTMF SIGNAL 17

4 DECIMATION 27

5 INTERPOLATION 35

6 POWER SPECTRAL DENSITY 41

7 FREQUENCY RESPONSE OF A SYSTEM 51

8 IIR LOW PASS FILTER 61

9 IIR HIGH PASS FILTER 73

10 FIR LOW PASS FILETR 85

11 FIR HIGH PASS FILETR 93

12 IMPLEMENTATION OF FAST FOURIER 99

TRANSFORM

LIST OF EXPERIMENTS

Department of Electronics and Communication Engineering Page 1


Mother Teresa Institute of Science and Technology, Sathupally

Exp No.: Date:

Department of Electronics and Communication Engineering Page 2


Mother Teresa Institute of Science and Technology, Sathupally

GENERATION OF SINUSOIDAL WAVE FORM

AIM: To write and excute MATLAB program for the generation of sinusoidal

wave form

APPARATUS REQUIRED:

Personal Computer

MATLAB -7.8 Version(R2009A)

THEORY:
A signal can be defined as a physical quantity, which

varies with respect to one or more independent variables.

Mathematically signal can be defined as a function which varies with

respect to time and conveys some information. Information may be

temperature, voltage,current,power etc.

Department of Electronics and Communication Engineering Page 3


Mother Teresa Institute of Science and Technology, Sathupally

ALGORITHM:

1.write a matlab code for generating sinusoidal wave form by using following
parameters

Department of Electronics and Communication Engineering Page 4


Mother Teresa Institute of Science and Technology, Sathupally

Frequency=1000hz; Vp-p=4V

2. Save and run the corresponding matlab file

3. If any errors occur correct those errors and again run the modified matlab file

4. Observe the output wave form

5. Plot the graph with the help of amplitude values those are obtained at
different time intervals.

PROGRAM:
% SINE WAVE GENERATION
clc; clear all; close all;

t = 0:0.000001:0.001;

f = 1000;

x = 4*sin (2*pi*f*t);

plot(t,x); grid

xlabel('time');

ylabel('amplitude');

title('generation of sinewave');

MODEL GRAPH:

Department of Electronics and Communication Engineering Page 5


Mother Teresa Institute of Science and Technology, Sathupally

RESULT:

Department of Electronics and Communication Engineering Page 6


Mother Teresa Institute of Science and Technology, Sathupally

Department of Electronics and Communication Engineering Page 7


Mother Teresa Institute of Science and Technology, Sathupally

Exp No.: Date:

Department of Electronics and Communication Engineering Page 8


Mother Teresa Institute of Science and Technology, Sathupally

DISCRETE FOURIER TRANSFORM

AIM: To write and excute matlab code for the discrete fourier transform of a

given DT signal

APPARATUS REQUIRED:

Personal Computer

MATLAB -7.8 Version(R2009A)

THEORY: The DFT of a finite duration sequence x(n) is obtained

by sampling the fourier transform x(exp(jw)) at N equally spaced

points over the interval 0 < w < 2Π with a spacing of 2 Π/n .

ALGORITHM:

1. Write a matlab code for the dft of a given sequence

2. Save and run the corresponding matlab file

3. If any errors occur correct those errors and again run the modified matlab file

4. Observe the output wave form

Department of Electronics and Communication Engineering Page 9


Mother Teresa Institute of Science and Technology, Sathupally

5. Plot the graph with the help of amplitude values those are obtained at

different time intervals.

Department of Electronics and Communication Engineering Page 10


Mother Teresa Institute of Science and Technology, Sathupally

PROGRAM :

% DFT

x= input('enter the input sequence');

y= fft(x);

subplot(2,1,1);

stem(x);

xlabel('n sequence');

ylabel('amplitude');

title('input sequence');

subplot(2,1,2);

plot(y,'*-');

xlabel('real axis');

ylabel('imaginary axis');

title('input sequence');

enter the input sequence=[1 2 3 4]


OUTPUT VALUES:

Department of Electronics and Communication Engineering Page 11


Mother Teresa Institute of Science and Technology, Sathupally

y=

Columns 1 through 3

10.0000 -2.0000 + 2.0000i -2.0000

Column 4

-2.0000 - 2.0000i

Department of Electronics and Communication Engineering Page 12


Mother Teresa Institute of Science and Technology, Sathupally

MODEL GRAPH:
Department of Electronics and Communication Engineering Page 13
Mother Teresa Institute of Science and Technology, Sathupally

RESULT:

Department of Electronics and Communication Engineering Page 14


Mother Teresa Institute of Science and Technology, Sathupally

KEYPAD STRUCTURE:

Department of Electronics and Communication Engineering Page 15


Mother Teresa Institute of Science and Technology, Sathupally

1 2 3
100 Hz

4 5 6
200 Hz

7 8 9 300 Hz

* 0 # 400Hz

1100 Hz 1200Hz 1300Hz

Exp No.: Date:

GENERATION OF DTMF SIGNAL


Department of Electronics and Communication Engineering Page 16
Mother Teresa Institute of Science and Technology, Sathupally

AIM: To write and excute matlab code for the generation of DTMF signal

APPARATUS REQUIRED:

Personal Computer
MATLAB -7.8 Version(R2009A)

THEORY:
A DTMF Signal consists of the sum of two sinusoids or tones with

frequencies taken from two mutually exclusive groups. These frequencies were

chosen to prevent any harmonics from being incorrectly detected by the receiver

as some other DTMF frequency, each pair of tones contain one frequency from

the low frequency group(100hz,200hz,300hz,400hz) and one frequency from

the high frequency group(1100hz,1200hz,1300hz) and represent a unique

symbol. The frequencies allocated to the keypad of telephone. DTMF signaling

is the basis of voice communications control and widely used worldwide is

modern telephony to dial numbers and configure switch boards. It is also used

in systems such as in voice mail, E-mail and telephone banking.

Department of Electronics and Communication Engineering Page 17


Mother Teresa Institute of Science and Technology, Sathupally

ALGORITHM:

1. write a matlab code for the DTMF signal generation with the help of low
frequency group,hih frequency group.
Department of Electronics and Communication Engineering Page 18
Mother Teresa Institute of Science and Technology, Sathupally

2. Save and run the corresponding matlab file

3. If any errors occur correct those errors and again run the modified matlab fil

4. Observe the output wave form

5. Plot the graph with the help of amplitude values those are obtained at
different time intervals.

PROGRAM:

% DTMF

clc; clear all; close all;

d = input ('enter digit');

symbol = abs(d);

if symbol == 1

f1=100;f2=1100;

end

if symbol == 2

f1=100;f2=1200;

end

if symbol == 3

f1=100;f2=1300;

Department of Electronics and Communication Engineering Page 19


Mother Teresa Institute of Science and Technology, Sathupally

end

if symbol==4

f1=200;f2=1100;

end
Department of Electronics and Communication Engineering Page 20
Mother Teresa Institute of Science and Technology, Sathupally

if symbol == 5

end

if symbol == 6

f1=200;f2=1300;

end

if symbol == 7

f1=300;f2=1100;

end

if symbol == 8

f1=300;f2=1200;

end

if symbol == 9

f1=300;f2=1300;

end

if symbol == 0

f1=400;f2=1200;

end

if symbol == 35

Department of Electronics and Communication Engineering Page 21


Mother Teresa Institute of Science and Technology, Sathupally

f1=400;f2=1100;

end

if symbol == 42

f1=400;f2=1300;
Department of Electronics and Communication Engineering Page 22
Mother Teresa Institute of Science and Technology, Sathupally

end

n= 0:100;

x= sin(2*pi*n*f1/8000)+sin(2*pi*f2/8000);

plot(x);

xlabel('nsequence');

ylabel('amplitude');

title('DTMF SIGNAL');

disp('low frequency is=');

disp(f1);

disp('high frequency is=');

disp(f2);

OUTPUT:

enter digit=5

low frequency is=

200

Department of Electronics and Communication Engineering Page 23


Mother Teresa Institute of Science and Technology, Sathupally

high frequency is=

1200

MODEL GRAPH:

RESULT:

Department of Electronics and Communication Engineering Page 24


Mother Teresa Institute of Science and Technology, Sathupally

BLOCK DIAGRAM:

x(n) LOW PASS FILTER w(n) y(M)


DOWN SAMPLER
Department of Electronics and Communication Engineering Page 25
Mother Teresa Institute of Science and Technology, Sathupally

fs fs/M

Exp No.: Date:


DECIMATION
AIM: To write and excute a matlab program for the decimation process.

APPARATUS REQUIRED:
Department of Electronics and Communication Engineering Page 26
Mother Teresa Institute of Science and Technology, Sathupally

Personal Computer
MATLAB -7.8 Version(R2009A)

THEORY:

A decimation filter is used to decrease the sampling rate. T of

he decrease in the sampling rate can be achieved by sampling dropping samples.

for instance, if every other sample of a sample sequence is dropped, the

sampling rate of the resulting sequence will be half that of the original

sequence. The problem with dropping samples is that the new sequence may be

violate the sampling thorem,which requires that the sampling frequency must be

greater than two times the highest frequency contents of the signal.

ALGORITHM:
1.Write a matlab program for decimation process.

2. Save and run the corresponding matlab file

3.If any errors occur correct those errors and again run the modified matlab file

4. Observe the output wave form

Department of Electronics and Communication Engineering Page 27


Mother Teresa Institute of Science and Technology, Sathupally

5. Plot the graph with the help of amplitude values those are obtained at

different time intervals.

PROGRAM:
% DECIMATION PROCESS

Department of Electronics and Communication Engineering Page 28


Mother Teresa Institute of Science and Technology, Sathupally

N=input('enter the length of input signal');

M=input('enter down sampling factor');

f1= input('enter input signal frequency');

n = 0 : N-1;

x= sin (2*pi*f1*n);

subplot(2,1,1);

stem(n,x);

xlabel('n sequence');

ylabel('amplitude');

title('input signal');

y= x(1:M:length(x));

subplot(2,1,2);

stem(y);

xlabel('n sequence');

ylabel('amplitude');

title('output signal');

OUTPUT:

Department of Electronics and Communication Engineering Page 29


Mother Teresa Institute of Science and Technology, Sathupally

enter the length of input signal=8


enter down sampling factor=2
enter input signal frequency=1000

MODEL GRAPH:

RESULT:

Department of Electronics and Communication Engineering Page 30


Mother Teresa Institute of Science and Technology, Sathupally

BLOCK DIAGRAM:

x(n) xz(M) y(M)


INSERT (L-1) LOW PASS
Department of Electronics and Communication Engineering Page 31
ZEROS(UP FILTER
SAMPLING)
Mother Teresa Institute of Science and Technology, Sathupally

Lfs Lfs

Exp No.: Date:


INTERPOLATION
AIM: To write and excute a matlab program for the interpolation process.

Department of Electronics and Communication Engineering Page 32


Mother Teresa Institute of Science and Technology, Sathupally

APPARATUS REQUIRED:

Personal Computer

MATLAB -7.8 Version(R2009A)

THEORY:
An interpolation filter is used to increase the sampling rate. The

interpolation process involves inserting samples b/w the incoming samples to

create additional samples to increase the sampling rate for the output..One way

to implement an interpolation filter is to first insert zeroes b/w samples of the

original sample sequence. The zero inserted sequence is passed through an

appropriate lowpass digital FIR filter to generate the interpolated sequence.

ALGORITHM:
1.Write a matlab program for decimation process.
2. Save and run the corresponding matlab file

3. If any errors occur correct those errors and again run the modified matlab file

4. Observe the output wave form

5. Plot the graph .

Department of Electronics and Communication Engineering Page 33


Mother Teresa Institute of Science and Technology, Sathupally

PROGRAM:
N = input('enter the length of input signal');

L = input('enter the up sampling factor');

Department of Electronics and Communication Engineering Page 34


Mother Teresa Institute of Science and Technology, Sathupally

f1=input('enter the input signal freq');

n = 0:N;

x= sin(2*pi*f1*n);

y=zeros(1,L*length(x));

y(1,L:length(y))=x;

plot(n,x,'green*-');hold on;

plot(y);hold off;

xlabel('time');

ylabel('amplitude');

title('INTERPOLATION');

OUTPUT:

enter the length of input signal4


enter the up sampling factor2

Department of Electronics and Communication Engineering Page 35


Mother Teresa Institute of Science and Technology, Sathupally

enter the input signal freq1000


MODEL GRAPH:

RESULT:

Department of Electronics and Communication Engineering Page 36


Mother Teresa Institute of Science and Technology, Sathupally

Department of Electronics and Communication Engineering Page 37


Mother Teresa Institute of Science and Technology, Sathupally

Exp No.: Date:


POWER SPECTRAL DENSITY

Department of Electronics and Communication Engineering Page 38


Mother Teresa Institute of Science and Technology, Sathupally

AIM: Write a matlab program for power spectral density of a signal.

APPARATUS REQUIRED:

Personal Computer
MATLAB -7.8 Version(R2009A)

THEORY:

The power spectral density (PSD) is a measurement of the energy

at various frequencies. spectrum is a Latin word for image. Auto correlation

function (ACF) is a measure of similarity between a signal and time delayed

version of same signal. Cross correlation function (CCF) is a measure of

similarity between a signal cross correlation function and time delayed version

of the different signals. Frequency domain representation of a ACF of

non periodic signal is known as energy spectral density(ESD)..Frequency domai

n representation of ACF of periodic signal is known as power spectral

density(PSD) .For non periodic signals ESD & ACF forms fourier

transformable parts.For periodic signals PSD&ACF forms fourier transformable

parts.

Department of Electronics and Communication Engineering Page 39


Mother Teresa Institute of Science and Technology, Sathupally

ALGORITHM:
1.write a matlab program for power spectral density of a given signal
Department of Electronics and Communication Engineering Page 40
Mother Teresa Institute of Science and Technology, Sathupally

2.enter the fft length1 and fft length2

3.save and run the program

4. Observe the output values

5.plot the graph.

PROGRAM:
%POWER SPECTRAL DENSITY

clc; cler all; close all;

f1= input ('enter the first sinusoidal frequency');

f2= input ('enter the first sinusoidal frequency');

n = input ('enter the length of input sequence');

n1= input ('enter the fft length1');

n2= input ('enter the fft length2');

fs = input('enter the sampling frequency')

t=0:1/fs/1;

x=sin (2*pi*f1*t) + sin(2*pi*f2*t);

pxx1= abs (fft (x,n1).^2/(n+1));

pxx1

Department of Electronics and Communication Engineering Page 41


Mother Teresa Institute of Science and Technology, Sathupally

pxx2= abs (fft (x,n2).^2/(n+1));

pxx2
Department of Electronics and Communication Engineering Page 42
Mother Teresa Institute of Science and Technology, Sathupally

subplot (2,1,1);

plot ((0:n1-1)/n1,10*log10(pxx1),'*-');

xlabel ('frequency');

ylabe l(‘power in db’);

title('PSD USING FFT LENGTH 1');

subplot(2,1,2);

plot((0:n2-1)/n2,10*log10(pxx2),'*-');

xlabel('frequency');

ylabel('power in db'); title('PSD USING FFT LENGTH 2');

OUTPUT:

enter the first sinusoidal frequency=700


Department of Electronics and Communication Engineering Page 43
Mother Teresa Institute of Science and Technology, Sathupally

enter the first sinusoidal frequency=800


enter the length of input sequence=5
enter the fft length1=6
enter the fft length2=7
enter the sampling frequency=8000

pxx1 =

7.4366 1.4982 0.0391 0.0068 0.0391 1.4982

pxx2 =

Columns 1 through 6

5.8719 3.4074 0.0922 0.0231 0.0231 0.0922


Column 7
3.4074

Department of Electronics and Communication Engineering Page 44


Mother Teresa Institute of Science and Technology, Sathupally

MODEL GRAPH:
Department of Electronics and Communication Engineering Page 45
Mother Teresa Institute of Science and Technology, Sathupally

RESULT:

Department of Electronics and Communication Engineering Page 46


Mother Teresa Institute of Science and Technology, Sathupally

Department of Electronics and Communication Engineering Page 47


Mother Teresa Institute of Science and Technology, Sathupally

Exp No.: Date:

Department of Electronics and Communication Engineering Page 48


Mother Teresa Institute of Science and Technology, Sathupally

FREQUENCY RESPONSE OF A SYSTEM

AIM: Write a matlab code for frequency response of a system

APPARATUS REQUIRED:

Personal Computer

MATLAB -7.8 Version(R2009A)

THEORY: Filter is a frequency selective device,which allows only specific

band of frequencies of input signal and attenuate all other unwanted frequencies

of input signal.Based on the frequency response of a filter, filters are classified

into 4 types

1.Low pass filter, 2.high pass filter,3.band pass filter,4.band stop filter

ALGORITHM:
1.Write a matlab program for frequency response of a system

2.run the program

3.enter the value s of a

4.enter the values of b

Department of Electronics and Communication Engineering Page 49


Mother Teresa Institute of Science and Technology, Sathupally

5.Observe the output

Department of Electronics and Communication Engineering Page 50


Mother Teresa Institute of Science and Technology, Sathupally

6.Plot the graph

PROGRAM:
%FREQUENCY RESPONSE OF A SYSTEM

a = input ('enter the values of a');

b = inpu t('enter the values of b');

w = logspace (-1,1);

x=freq z (b,a,w);

mag = abs(10*log10(x));

mag

phase = angle(x);

phase

subplot(2,1,1);

loglog(mag,'*');grid on

xlabel('frequency');

ylabel('magnitude in db’s')

title('magnitude plot');

subplot(2,1,2);

semilogx(phase,'*-');

grid on;

xlabel ('frequency');

Department of Electronics and Communication Engineering Page 51


Mother Teresa Institute of Science and Technology, Sathupally

ylabel ('phase');

Department of Electronics and Communication Engineering Page 52


Mother Teresa Institute of Science and Technology, Sathupally

title ('phase plot');

OUTPUT:

Department of Electronics and Communication Engineering Page 53


Mother Teresa Institute of Science and Technology, Sathupally

enter the values of a=[1 2 3 4]


enter the values of b=[1 0 2 3]
mag =
Columns 1 through 6
2.2227 2.2236 2.2246 2.2259 2.2274 2.2292
Columns 7 through 12
2.2315 2.2342 2.2374 2.2413 2.2461 2.2518
Columns 13 through 18
2.2587 2.2670 2.2771 2.2893 2.3040 2.3217
Columns 19 through 24
2.3429 2.3684 2.3987 2.4344 2.4755 2.5210
Columns 25 through 30
2.5675 2.6067 2.6213 2.5809 2.4443 2.1778
Columns 31 through 36
1.8011 1.4540 1.3701 1.6506 2.2703 3.4121
Columns 37 through 42
6.1562 8.6538 3.7095 2.0518 1.3583 2.0772
Columns 43 through 48
2.6194 2.3669 2.2189 2.3620 2.5842 1.3614
Columns 49 through 50
4.4933 2.7784

Department of Electronics and Communication Engineering Page 54


Mother Teresa Institute of Science and Technology, Sathupally

phase =

Department of Electronics and Communication Engineering Page 55


Mother Teresa Institute of Science and Technology, Sathupally

Columns 1 through 6
-0.0168 -0.0185 -0.0204 -0.0224 -0.0247 -0.0272
Columns 7 through 12
-0.0300 -0.0332 -0.0367 -0.0406 -0.0450 -0.0499
Columns 13 through 18
-0.0556 -0.0620 -0.0694 -0.0780 -0.0880 -0.0999
Columns 19 through 24
-0.1141 -0.1312 -0.1523 -0.1783 -0.2111 -0.2524
Columns 25 through 30
-0.3044 -0.3681 -0.4405 -0.5089 -0.5433 -0.4988
Columns 31 through 36
-0.3456 -0.1165 0.1136 0.3154 0.5157 0.7733
Columns 37 through 42
1.1796 -1.3717 -0.8300 -0.4547 -0.0762 0.4659
Columns 43 through 48
0.4073 0.1302 0.0054 -0.1269 -0.5065 0.0902
Columns 49 through 50
0.9637 -0.6396

Department of Electronics and Communication Engineering Page 56


Mother Teresa Institute of Science and Technology, Sathupally

MODEL GRAPH:

Department of Electronics and Communication Engineering Page 57


Mother Teresa Institute of Science and Technology, Sathupally

RESULT:

Department of Electronics and Communication Engineering Page 58


Mother Teresa Institute of Science and Technology, Sathupally

Department of Electronics and Communication Engineering Page 59


Mother Teresa Institute of Science and Technology, Sathupally

Department of Electronics and Communication Engineering Page 60


Mother Teresa Institute of Science and Technology, Sathupally

Exp No.: Date:

IIR LOW PASS FILTER

AIM: To write and excute the matlab program for IIR Low pass filetr

APPARATUS REQUIRED:

Personal Computer

MATLAB -7.8 Version(R2009A)

THEORY:
IIR filters may be implemented as either analog or digital filters. In digital IIR

filters, the output feedback is immediately apparent in the equations defining the output. Note

that unlike FIR filters, in designing IIR filters it is necessary to carefully consider the "time

zero" case in which the outputs of the filter have not yet been clearly defined as design of

digital IIR filters is heavily dependent on that of their analog counterparts because there are

plenty of resources, works and straightforward design methods concerning analog feedback

filter design while there are hardly any for digital IIR filters. As a result, usually, when a

digital IIR filter is going to be implemented, an analog filter (e.g. Chebyshev filter,

Butterworth filter, Elliptic filter) is first designed and then is converted to a digital filter by

applying discretization techniques such as Bilinear transform or Impulse invariance.

Examples of IIR filters include the Chebyshev filter, Butterworth filter, and the Bessel filter.

Department of Electronics and Communication Engineering Page 61


Mother Teresa Institute of Science and Technology, Sathupally

Department of Electronics and Communication Engineering Page 62


Mother Teresa Institute of Science and Technology, Sathupally

ALGORITHM:
1) Enter the pass band ripple (rp) and stop band ripple (rs).

2) Enter the pass band frequency (fp) and stop band frequency (fs).

3) Get the sampling frequency (f), beta value.

4) Calculate the analog pass band edge frequencies, w1 and w2.

w1 = 2*fp/f

w2 = 2*fs/f

5) calculate the numerator and denominator

6)Use an If condition and ask the user to choose either Rectangular Window or

Triangular

window or Kaiser window..

7)use rectwin,triang,kaiser commands

8) Calculate the magnitude of the frequency response in decibels (dB

m=20*log10(abs(h))

9) Plot the magnitude response [magnitude in dB Vs normalized frequency

(om/pi)]

10)Give relevant names to x and y axes and give an appropriate title for the plot.

Department of Electronics and Communication Engineering Page 63


Mother Teresa Institute of Science and Technology, Sathupally

Department of Electronics and Communication Engineering Page 64


Mother Teresa Institute of Science and Technology, Sathupally

PROGRAM:
% IIR filters
clc;

clear all;

close all;

warning off;

disp('enter the IIR filter design specifications');

rp=input('enter the passband ripple=');

rs=input('enter the stopband ripple=');

wp=input('enter the passband freq=');

ws=input('enter the stopband freq=');

fs=input('enter the sampling freq=');

w1=2*wp/fs;w2=2*ws/fs;

[n,wn]=buttord(w1,w2,rp,rs,'s'); % Find the order n and cutt off frequency

disp('Frequency response of IIR LPF is:');

[b,a]=butter(n,wn,'low','s'); % Find the filter co-efficients of LPF

w=0:.01:pi;

[h,om]=freqs(b,a,w); % Plot the frequency response

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

subplot(2,1,1);

plot(om/pi,m); grid

xlabel('(a) Normalized freq. -->');

Department of Electronics and Communication Engineering Page 65


Mother Teresa Institute of Science and Technology, Sathupally

Department of Electronics and Communication Engineering Page 66


Mother Teresa Institute of Science and Technology, Sathupally

ylabel('Gain in dB-->');

an=angle(h);

subplot(2,1,2);

plot(om/pi,an);

xlabel('(b) Normalized freq. -->');

ylabel('Phase in radians-->');

title('phase response of IIR Low Pass filter is:');

Department of Electronics and Communication Engineering Page 67


Mother Teresa Institute of Science and Technology, Sathupally

OUTPUT:

enter the IIR filter design specifications


enter the passband ripple=0.15
enter the stopband ripple=60
enter the passband freq=1500
enter the stopband freq=3000
enter the sampling freq=7000
Frequency response of IIR LPF is:

Department of Electronics and Communication Engineering Page 68


Mother Teresa Institute of Science and Technology, Sathupally

Department of Electronics and Communication Engineering Page 69


Mother Teresa Institute of Science and Technology, Sathupally

MODEL GRAPH:

Department of Electronics and Communication Engineering Page 70


Mother Teresa Institute of Science and Technology, Sathupally

RESULT:

Department of Electronics and Communication Engineering Page 71


Mother Teresa Institute of Science and Technology, Sathupally

Department of Electronics and Communication Engineering Page 72


Mother Teresa Institute of Science and Technology, Sathupally

Exp No.: Date:

IIR HIGH PASS FILTER

AIM: To write and excute the matlab program for IIR Low pass filetr

APPARATUS REQUIRED:

Personal Computer

MATLAB -7.8 Version(R2009A)

THEORY:
Analog prototype filter is a low-pass filter with the cut-off frequency Ωp

= 1. Its transformation to a high-pass analog filter can be split into two steps.

The first step refers to the transformation to a high-pass analog filter, whereas

the second one refers to frequency scaling. The final objective is that passband

cut-off frequency of the resulting high-pass analog filter amounts to Ωc.

ALGORITHM:

1) Enter the pass band ripple (rp) and stop band ripple (rs).

2) Enter the pass band frequency (fp) and stop band frequency (fs).

3) Get the sampling frequency (f).

4) Calculate the analog pass band edge frequencies, w1 and w2.

Department of Electronics and Communication Engineering Page 73


Mother Teresa Institute of Science and Technology, Sathupally

Department of Electronics and Communication Engineering Page 74


Mother Teresa Institute of Science and Technology, Sathupally

w1 = 2*fp/f

w2 = 2*fs/f

5) Calculate the order and 3dB cutoff frequency of the analog filter. [Make use

of the following function]

[n,wn]=buttord(w1,w2,rp,rs,.s.)

6) Design an nth order analog high pass Butter worth filter using the following

statement.

[b,a]=butter(n,wn,.high.,.s.)

7) Find the complex frequency response of the filter by using „freqs( ). function

[h,om]=freqs(b,a,w) where, w = 0:.01:pi

This function returns complex frequency response vector „h. and frequency

vector „om. in radians/samples of the filter.

8) Calculate the magnitude of the frequency response in decibels (dB

m=20*log10(abs(h))

9) Plot the magnitude response [magnitude in dB Vs normalized frequency

(om/pi)]

10) Calculate the phase response using an = angle(h)

Department of Electronics and Communication Engineering Page 75


Mother Teresa Institute of Science and Technology, Sathupally

Department of Electronics and Communication Engineering Page 76


Mother Teresa Institute of Science and Technology, Sathupally

11) Plot the phase response [phase in radians Vs normalized frequency (om/pi)]

12) Give relevant names to x and y axes and give an appropriate title for the

plot.

13)Plot all the responses in a single figure window.[Make use of subplot]

PROGRAM:

% IIR filters

clc;

clear all;

close all;

warning off;

disp('enter the IIR filter design specifications');

rp=input('enter the passband ripple=');

rs=input('enter the stopband ripple=');

wp=input('enter the passband freq=');

ws=input('enter the stopband freq=');

fs=input('enter the sampling freq=');

w1=2*wp/fs;w2=2*ws/fs;

[n,wn]=buttord(w1,w2,rp,rs,'s'); % Find the order n and cutt off frequency

disp('Frequency response of IIR HPF is:');

[b,a]=butter(n,wn,'low','s'); % Find the filter co-efficients of LPF

Department of Electronics and Communication Engineering Page 77


Mother Teresa Institute of Science and Technology, Sathupally

Department of Electronics and Communication Engineering Page 78


Mother Teresa Institute of Science and Technology, Sathupally

w=0:.01:pi;

[h,om]=freqs(a,b,w); % Plot the frequency response

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

subplot(2,1,1);

plot(om/pi,m); grid

title('magnitude response of IIR HIGH Pass filter is:');

xlabel('(a) Normalized freq. -->');

ylabel('Gain in dB-->'

an=angle(h);

subplot(2,1,2);

plot(om/pi,an);grid

xlabel('(b) Normalized freq. -->');

ylabel('Phase in radians-->');

title('phase response of IIR HIGH Pass filter is:');

Department of Electronics and Communication Engineering Page 79


Mother Teresa Institute of Science and Technology, Sathupally

OUTPUT:

enter the IIR filter design specifications

enter the passband ripple=0.15

enter the stopband ripple=60

enter the passband freq=1500

enter the stopband freq=3000

enter the sampling freq=7000

Frequency response of IIR HPF is:

Department of Electronics and Communication Engineering Page 80


Mother Teresa Institute of Science and Technology, Sathupally

Department of Electronics and Communication Engineering Page 81


Mother Teresa Institute of Science and Technology, Sathupally

MODEL GRAPH:

Department of Electronics and Communication Engineering Page 82


Mother Teresa Institute of Science and Technology, Sathupally

RESULT:

Department of Electronics and Communication Engineering Page 83


Mother Teresa Institute of Science and Technology, Sathupally

Department of Electronics and Communication Engineering Page 84


Mother Teresa Institute of Science and Technology, Sathupally

Exp No.: Date:

FIR LOW PASS FILTER DESIGN

AIM:To Design FIR LP Filter using Rectangular/Triangular/kaiser Windowing

Technique.

APPARATUS REQUIRED:

Personal Computer

MATLAB -7.8 Version(R2009A)

THEORY:

The filter is said to be an FIR filter if it’s impulse response is finite. It

is a discrete time system that is designed to pass the spectral contents of the

input signal in a specified band of frequencies. There are so many approximatio

n solutions to design digital filters among them popular approximations are butt

erwort approximation, Chebyshev approximation. Here first we have to design

analog filters, and then we can obtain digital filters with the help of transformati

on techniques. There are two types of transformation techniques. Those are imp

ulse invariant Transformation, Bilinear transformation.

Department of Electronics and Communication Engineering Page 85


Mother Teresa Institute of Science and Technology, Sathupally

Department of Electronics and Communication Engineering Page 86


Mother Teresa Institute of Science and Technology, Sathupally

ALGORITHM:

1. Write a matlab program for FIR low pass filter by using windowing

technique

2. Save the program

3. Observe the output

4. Plot the graph

PROGRAM:

% FIR LOW PASS FILTER

wc=0.5;

n=24;

b=fir1(n,wc,boxcar(n+1));% rectangular window

w=0:0.01:pi;

h=freqz(b,1,w);

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

plot(w,mag);grid on;

hold on;

b=fir1(n,wc,bartlett(n+1));% triangular window

w=0:0.01:pi;

h=freqz(b,1,w);

Department of Electronics and Communication Engineering Page 87


Mother Teresa Institute of Science and Technology, Sathupally

Department of Electronics and Communication Engineering Page 88


Mother Teresa Institute of Science and Technology, Sathupally

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

plot(w,mag);grid on;

hold off;

xlabel('frequency');

ylabel('magnitude');

title('rectangular and triangular windows');

legend('rectangular window’, triangular window');

Department of Electronics and Communication Engineering Page 89


Mother Teresa Institute of Science and Technology, Sathupally

MODEL GRAPH:

Department of Electronics and Communication Engineering Page 90


Mother Teresa Institute of Science and Technology, Sathupally

RESULT:

Department of Electronics and Communication Engineering Page 91


Mother Teresa Institute of Science and Technology, Sathupally

Department of Electronics and Communication Engineering Page 92


Mother Teresa Institute of Science and Technology, Sathupally

Exp No.: Date:

FIR HIGH PASS FILTER DESIGN

AIM:To Design FIR LP Filter using Rectangular/Triangular/kaiser Windowing

Technique.

APPARATUS REQUIRED:

Personal Computer

MATLAB -7.8 Version(R2009A)

THEORY:

The filter is said to be an FIR filter if it’s impulse response is finite.It

is a discrete time system that is designed to pass the spectral contents of the

input signal in a specified band of frequencies. There are so many

approximation solutions to design digital filters among them popular

approximations are butterwort approximation, Chebyshev approximation. Here

first we have to design analog filters, and then we can obtain digital filters with

the help of transformation techniques. There are two types of transformation

techniques.Those are impulse invariant Transformation, Bilinear transformation

Department of Electronics and Communication Engineering Page 93


Mother Teresa Institute of Science and Technology, Sathupally

Department of Electronics and Communication Engineering Page 94


Mother Teresa Institute of Science and Technology, Sathupally

ALGORITHM:

1.Write a matlab program for FIR high pass filter by using windowing

technique

2.Save the program

3.Observe the output

4.Plot the graph

PROGRAM:

% FIR HIGH PASS FILTER

wc=0.5;

n=24;

b=fir1(n,wc,'high',boxcar(n+1));% rectangular window

w=0:0.01:pi;

h=freqz(b,1,w);

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

plot(w,mag);grid on;

hold on;

b=fir1(n,wc,'high',bartlett(n+1));% triangular window

w=0:0.01:pi;

h=freqz(b,1,w);

Department of Electronics and Communication Engineering Page 95


Mother Teresa Institute of Science and Technology, Sathupally

MODEL GRAPH:

Department of Electronics and Communication Engineering Page 96


Mother Teresa Institute of Science and Technology, Sathupally

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

plot(w,mag,'*');grid on;

hold off;

xlabel('frequency');

ylabel('magnitude');

title('FIR HPF FREQUENCY RESPONSE');

RESULT:

Department of Electronics and Communication Engineering Page 97


Mother Teresa Institute of Science and Technology, Sathupally

Department of Electronics and Communication Engineering Page 98


Mother Teresa Institute of Science and Technology, Sathupally

Exp No.: Date:

FAST FOURIER TRANSFORM

AIM: To perform the FFT of signal x(n) using Mat lab.

APPARATUS REQUIRED:

Personal Computer

MATLAB -7.8 Version(R2009A)

THEORY:
A fast Fourier transform (FFT) is an efficient algorithm to compute the

discrete Fourier transform (DFT) and its inverse. FFTs are of great importance

to a wide variety of applications, from digital signal processing and solving

partial differential equations to algorithms for quick multiplication of large

integers. Evaluating the sums of DFT directly would take O(N 2) arithmetical

operations. An FFT is an algorithm to compute the same result in only O(N log

N) operations. In general, such algorithms depend upon the factorization of N,

but there are FFTs with O(N log N) complexity for all N, even for prime

N.Since the inverse DFT is the same as the DFT, but with the opposite sign in

the exponent and a 1/N factor, any FFT algorithm can easily be adapted for it as

well.

Department of Electronics and Communication Engineering Page 99


Mother Teresa Institute of Science and Technology, Sathupally

Department of Electronics and Communication Engineering Page 100


Mother Teresa Institute of Science and Technology, Sathupally

ALGORITHM:
1. Write a matlab program for FFT .

2. Save the program

3. Observe the output

4. Plot the graph

PROGRAM:

clc;clear all; close all;

N=8;

m=8;

a=input('Enter the input sequence');

n=0:1:N-1;

subplot(2,2,1);

stem(n,a);

xlabel('Time Index n');

ylabel('Amplitude');

title('Sequence');

x=fft(a,m);

k=0:1:N-1;

subplot(2,2,2);

Department of Electronics and Communication Engineering Page 101


Mother Teresa Institute of Science and Technology, Sathupally

Department of Electronics and Communication Engineering Page 102


Mother Teresa Institute of Science and Technology, Sathupally

stem(k,abs(x));

ylabel('magnitude');

xlabel('Frequency Index K');

title('Magnitude of the DFT sample');

subplot(2,2,3);

stem(k,angle(x));

xlabel('Frequency Index K');

ylabel('Phase');

title('Phase of DFT sample');

Department of Electronics and Communication Engineering Page 103


Mother Teresa Institute of Science and Technology, Sathupally

Enter the input sequence=[1 1 1 1 0 0 0 0]

MODEL GRAPH:

Department of Electronics and Communication Engineering Page 104


Mother Teresa Institute of Science and Technology, Sathupally

RESULT:.

Department of Electronics and Communication Engineering Page 105

You might also like