0% found this document useful (0 votes)
64 views

DSP Practical File

The document contains an index of 8 experiments related to signal processing. Experiment 1 involves generating various signal sequences like unit step, exponential, ramp, impulse, cosine and sine signals using MATLAB programs. Experiments 2 and 3 develop programs for discrete convolution and correlation respectively. Experiment 4 explains the sampling theorem. Experiments 5-8 involve designing analog low pass, high pass, band pass and band stop filters respectively using Butterworth filter design in MATLAB.

Uploaded by

Divya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views

DSP Practical File

The document contains an index of 8 experiments related to signal processing. Experiment 1 involves generating various signal sequences like unit step, exponential, ramp, impulse, cosine and sine signals using MATLAB programs. Experiments 2 and 3 develop programs for discrete convolution and correlation respectively. Experiment 4 explains the sampling theorem. Experiments 5-8 involve designing analog low pass, high pass, band pass and band stop filters respectively using Butterworth filter design in MATLAB.

Uploaded by

Divya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

INDEX

S. NO. EXPERIMENT REMARKS

1.(A) Program for generation of Unit step sequence.

1.(B) Program for generation of exponential sequence.

1.(C) Program for generation of Unit ramp sequence.

1.(D) Program for generation of Unit impulse sequence.

1.(E) Program for generation of cosine sequence.

1.(F) Program for generation of sine sequence.

2. Program for discrete convolution.

3. Program for Correlation.

4. Program for Sampling Theorem.

5. To design analog low pass filter.

6. To design analog high pass filter.

7. To design analog band pass filter.

8. To design analog band stop filter.


EXPERIMENT NO. : 1(A)

AIM :- TO REPRESENT UNIT STEP SIGNAL

PROGRAM :-

clc;
clear all;
close all;
n=[0:0.5:20];
a=input('enter value ofa');
y=(a).^n;
subplot(2,2,2);
stem(n,y);
xlabel('a');
ylabel('exponent');
title('expo2');

OUTPUT :-
EXPERIMENT NO. : 1(B)

AIM :- TO REPRESENT EXPONENTIAL SIGNAL.

PROGRAM:-

clc;
clear all;
close all;
n=[0:0.5:20];
x=input('enter value of x');
y=exp(x*n);
subplot(2,2,1);
stem(n,y);
xlabel('x');
ylabel('exponent');
title('expo1');

OUTPUT :-
EXPERIMENT NO. : 1(C)

AIM :- TO REPRESENT RAMP SIGNAL.

PROGRAM:-

%clc;
%clear all;
%close all;
n=[0:0.5:20];
subplot(2,2,3);
stem(n,n);
xlabel('x');
ylabel('y');
title('unit
ramp');

OUTPUT :-
EXPERIMENT NO. : 1(D)
AIM :- TO REPRESENT IMPULSE SIGNALS.

PROGRAM:-

IMPULSE
clc;
clear all;
close all;
t=[-3:1:2];
n1=[zeros(1,3),ones(1,1),zeros(1,2)];
subplot(2,2,4);
stem(t,n1);
xlabel('x');
ylabel('y');
title('unit
impulse');

OUTPUT :-
EXPERIMENT NO. : 1(E)

AIM :- TO REPRESENT COSINE SIGNALS.

PROGRAM:-

clc;
clear all;
close all;
t=[0:0.1:pi];
y=cos(2*pi*t);
subplot(2,2,1);
stem(t,y);
xlabel('t');
ylabel('coz');
title('cos(2pit)');

OUTPUT :-
EXPERIMENT NO. : 1(F)

AIM :- TO REPRESENT SINE SIGNALS.

PROGRAM:-

sine
clc;
clear all;
close all;
t=[0:0.1:pi];
y=sin(2*pi*t);
subplot(2,2,2);
stem(t,y);
xlabel('t');
ylabel('sin');
title('sin(2pit)');

OUTPUT :-
EXPERIMENT NO. : 2

AIM :- TO DEVELOP A PROGRAM FOR DISCRETE CONVOLUTION.

PROGRAM:-

clc,
clear
all;
close all;
x=[1 2 3 5];
h=[2 3 5 6];
y=conv(x,h);
subplot(3,1,1);
stem(x);
xlabel('x');
ylabel('amplitude');
title('x sequence');
subplot(3,1,2);
stem(h);
xlabel('h');
ylabel('amplitude');
title('h sequence');
subplot(3,1,3);
stem(y);
xlabel('y');
ylabel('amplitude');
title('y sequence');
: OUTPUT :-
EXPERIMENT NO. : 3

AIM :- TO DEVELOP A PROGRAM FOR DISCRETE CORRELATION.

PROGRAM:-

clc,
clear
all;
close all;
x=[1 2 3 5];
h=[2 3 5 6];
y=xcorr(x,h);
subplot(3,1,1);
stem(x);
xlabel('x');
ylabel('amplitude');
title('x sequence');
subplot(3,1,2);
stem(h);
xlabel('h');
ylabel('amplitude');
title('h sequence');
subplot(3,1,3);
stem(y);
xlabel('y');
ylabel('amplitude');
title('y sequence');
OUTPUT :-
EXPERIMENT NO. : 4

AIM: - TO UNDERSTAND SAMPLING THEOREM

PROGRAM: -
clc;
clearall;
closeall;
f1=1/128;
f2=5/128;
n=0:127;
fc=50/128;
x=cos(2*pi*f1*n)+cos(2*pi*f2*n);
xa=cos(2*pi*fc*n);
xamp=x.*xa;
subplot(4,1,1);
stem(n,x);
title('modulating wave');
xlabel('n');
ylabel('x');
subplot(4,1,2);
stem(n,xa);
title('carrier wave');
xlabel('n');
ylabel('xa');
subplot(4,1,3);
stem(n,xamp);
title('amplitude modulated wave');
xlabel('n');
ylabel('xamp');
n1=128;
xam=fft(xamp,n1);
subplot(4,1,4);
stem(n,xam);
xlabel('time');
ylabel('amplitude');
OUTPUT :-
modulating wave

2
0
x
20 40 -2
60 80 100 120 140 n
0
carrier wave

1
xa

0
20 40 60
-1 80 100 120 140 n
0
amplitude modulated wave
xamp

2
0
20 40 -2
60 80 100 120 140 n
0
amplitude

50
0
20-50
40 60 80 100 120 140 time
0
EXPERIMENT NO. : 5(A)

AIM :- To design analog low pass filter.

PROGRAM: -

clear all;
clc;
rp = input(‘pass ripple freq’);
rs = input(‘stop ripple freq’);
fp = Input(‘pass band freq’);
fs = input(‘stop band freq’);
f = input(‘sample freq’);
w1= 2*fp/f;
w2=2*fs/f;
[n,wn]= buttord(w1 ,w2,rp,rs);
[z,p,k]=butter(n,wn);
[b,a]=zp2tf(z,p,k);
[b,a]= butter(n,wn);
w=0:0.1:pi;
[h,p]= freqz(b,a,w);
g= 20* log 10(abs(h));
A=angle(h);
subplot (2,2,1); plot(p/pi,g);
ylabel(‘amp’);
xlabel(‘ferq’);
title(‘amp,freq’);
subplot (2,2,2); plot(p/pi,A);
xlabel(‘normal. freq’);
ylabel(‘phase’);
title(‘normal. freq,phase’);

Command Window of Analog Low pass :


rp = 0.5000
stop ripple freq40
rs= 40
pass band freq2000
fp= 2000
stop band freq3 000
fs= 3000
sample freq1000
f= 10000
w1 = 0.4000
w2 = 0.6000
n=9
wn =0.43 92
z=-1
—1
—1
—1
—1
—1
—1
—1

OUTPUT :-
EXPERIMENT NO. : 6

AIM :- To design analog high pass filter.

PROGRAM :-

clc;
clear all;
rp = input(‘pass ripple freq’);
rs = input(‘stop ripple freq’);
fp = input(‘pass band freq’);
fs = input(‘stop band freq’);
f= input(‘sample freq’);
w1= 2*fp/f;
w2= 2*fs/f;
[n,wn]= buttord(w1 ,w2,rp,rs);
[b,a]= butter(n,wn ‘high’);
w=0:0.1 :pi;
[h,p]= freqz(b,a,w);
g= 20*log10(abs(h));
A=angle(h);
subplot (2,2,1); plot(p/pi,g);
ylabel(‘amp’);
xlabel(‘ferq’);
title(‘amp,freq’);
subplot (2,2,2); plot(p/pi,A);
xlabel(‘normal. freq’);
ylabel(‘phase’);
title(‘normal. Freq,phase’);

OUTPUT :-
EXPERIMENT NO. : 7

AIM :-To design analog band pass filter.

PROGRAM :-

clc;
clear all;
rp = input(‘pass ripple freq’);
rs = input(‘stop ripple freq’);
fp = input(‘pass band freq’);
fs = input(‘stop band freq’);
f = input(‘sample freq’);
w1 = 2*fp/f;
w2= 2*fs/f;
[nJ= buttord(w1 ,w2,rp,rs);
wn= [w1,w2];
[b,a]= butter(n,wn,’bandpass’);
w=0:0.1:pi;
[h,p]= freqz(b,a,w);
g= 20*log10(abs(h));
A=angle(h);
subplot (2,2,1); plot(p/pi,g);
ylabel(‘amp’);
xlabel(‘ferq’);
title(‘amp,freq’);
subplot (2,2,2); plot(p/pi,A);
xlabel(‘normal. freq’);
ylabel(‘phase’);
title(‘normal. freq,phas&);

OUTPUT :-
EXPERIMENT NO. : 8

AIM :- To design analog band stop filter.

PROGRAM :-

clc;
clear all;
rp = input(‘pass ripple freq’);
rs = input(‘stop ripple freq’);
fp = input(‘pass band freq’);
fs = input(‘stop band freq’);
f= input(‘sample freq’);
w1= 2*fp/f;
w2= 2*fs/f
[n]= buttord(w1,w2,rp,rs);
wn=[w1,w2];
[b,a] = butter(n,wn,’stop’);
w=0:0.1:pi;
[h,p]= freqz(b,a,w);
g= 20*log10(abs(h));
A=angle(h);
subplot (2,2,1); plot(p/pi,g);
ylabel(‘amp’);
xlabel(‘ferq’);
title(‘amp,freq’);
subplot (2,2,2); plot(p/pi,A);
xlabel(‘normal. freq’);
ylabel(‘phase’);
title(‘normal. freq,phase’);

OUTPUT :-

You might also like