DSP Practical File
DSP Practical File
DSP Practical File
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)
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)
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)
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)
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
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
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
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)
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’);
OUTPUT :-
EXPERIMENT NO. : 6
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
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
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 :-