Professional Documents
Culture Documents
Digital Signal
Processing
Vikas Kumar
C07558
EECE, 7th SEM
Digital Signal Processing
EXPERIMENT NO. 1
EXPERIMENT 1(a)
Program Code:
clc;
clear all;
close all;
x=linspace(0,2*pi,100);
plot(x,sin(x))
xlabel('x-axistime');
ylabel('sin(x)');
title('sinewave');
axis('equal');
grid on;
Output Window:
Manish Bansal
C07521, 7th Sem, EECE. Page 1
Digital Signal Processing
EXPERIMENT 1(b)
Program Code:
clc;
clear all;
close all;
x=linspace(0,2*pi,100);
plot3(cos(x),sin(x),x)
xlabel('x');
ylabel('y');
zlabel('z');
zlatitle('spacecurve');
grid on;
Output Window:
Manish Bansal
C07521, 7th Sem, EECE. Page 2
Digital Signal Processing
EXPERIMENT 1(c)
Program Code:
clc;
clear all;
close all;
r=1;
theta=linspace(0,2*pi,100);
x=r*sin(theta);
y=r*cos(theta);
plot(x,y)
xlabel('x');
ylabel('y');
title('circle');
axis('equal');
grid on;
Output Window:
Manish Bansal
C07521, 7th Sem, EECE. Page 3
Digital Signal Processing
EXPERIMENT 1(d)
Program Code:
clc;
clear all;
close all;
t=linspace(0,2*pi,100);
x=cos(t);
y=sin(t);
z=tan(t);
k=exp(t);
subplot(1,4,1);
plot(t,x)
grid on;
axis('equal');
xlabel('time');
ylabel('cos(t)');
title('graph1');
subplot(1,4,2);
plot(t,y)
grid on;
axis('equal');
xlabel('time');
ylabel('sin(t)');
title('graph2');
subplot(1,4,3);
plot(t,z)
grid on;
axis('equal');
xlabel('time');
ylabel('tan(t)');
title('graph3');
subplot(1,4,4);
plot(t,k)
grid on;
axis('equal');
xlabel('time');
ylabel('exp(t)');
title('graph4');
Manish Bansal
C07521, 7th Sem, EECE. Page 4
Digital Signal Processing
Output Window:
Manish Bansal
C07521, 7th Sem, EECE. Page 5
Digital Signal Processing
EXPERIMENT 1(e)
x=
1 2 3
4 5 6
7 8 9
ans =
30 36 42
66 81 96
102 126 150
ans =
1 4 7
2 5 8
3 6 9
ans =
14 32 50
32 77 122
50 122 194
ans =
1 8 21
8 25 48
21 48 81
Manish Bansal
C07521, 7th Sem, EECE. Page 6
Digital Signal Processing
ans =
1 0 0
0 1 0
0 0 1
ans =
1
5
9
>> x^2 (multiplication of x matrix with itself)
ans =
30 36 42
66 81 96
102 126 150
eigvec =
eigval =
16.1168 0 0
0 -1.1168 0
0 0 -0.0000
Manish Bansal
C07521, 7th Sem, EECE. Page 7
Digital Signal Processing
EXPERIMENT NO. 2
EXPERIMENT 2(a)
Program Code:
clc;
clear all;
close all;
t=-9:1:9;
y=[zeros(1,9),ones(1,1),zeros(1,9)];
stem(t,y);
grid on;
Output Window:
Manish Bansal
C07521, 7th Sem, EECE. Page 8
Digital Signal Processing
EXPERIMENT 2(b)
Program Code:
clc;
clear all;
close all;
n=input('enter value of n');
t=0:1:n-1;
y=ones(1,n);
stem(t,y);
grid on;
Output Window:
Manish Bansal
C07521, 7th Sem, EECE. Page 9
Digital Signal Processing
EXPERIMENT 2(c)
Program Code:
clc;
clear all;
close all;
n=input('enter value of n');
t=0:n;
stem(t,t);
grid on;
Output:
enter value of n6
Output Window:
Manish Bansal
C07521, 7th Sem, EECE. Page 10
Digital Signal Processing
EXPERIMENT 2(d)
Program Code:
clc;
clear all;
close all;
x=input('enter first sequence');
h=input('enter second sequence');
y=conv(x,h);
subplot(1,3,1)
stem(x);
xlabel('t');
ylabel('x');
subplot(1,3,2)
stem(h);
xlabel('t');
Manish Bansal
C07521, 7th Sem, EECE. Page 11
Digital Signal Processing
ylabel('h');
subplot(1,3,3)
stem(y);
xlabel('t');
ylabel('y');
display('the result is: ');
y
grid on;
Output:
Output Window:
Manish Bansal
C07521, 7th Sem, EECE. Page 12
Digital Signal Processing
Result:
1 3 6 10 9 7 4
EXPERIMENT 3
Manish Bansal
C07521, 7th Sem, EECE. Page 13
Digital Signal Processing
Aim : Write a program to perform linear convolution and plot a graph for the
resultant function.
Program Code:
clc;
clear all;
close all;
a=input('enter the value of a');
b=input('enter the value of b');
m1=input('enter the range of a');
m2=input('enter the range of b');
stem(m1,a)
figure;
stem(m2,b)
figure;
m=m1(1,1)+m2(1,1);
n=m1(1,end)+m2(1,end);
j=[m:1:n];
c=conv(a,b);
stem (j,c)
c
Output:
c=
Output Window:
Manish Bansal
C07521, 7th Sem, EECE. Page 14
Digital Signal Processing
Manish Bansal
C07521, 7th Sem, EECE. Page 15
Digital Signal Processing
Manish Bansal
C07521, 7th Sem, EECE. Page 16
Digital Signal Processing
EXPERIMENT 4(a)
Program Code:
clc;
clear all;
close all;
a=[1,0.2,0.5];
b=[1,-0.5];
n=4;
a=[a zeros(1,n-1)];
x=deconv(a,b);
stem(x);
x
grid on;
Output Window:
Manish Bansal
C07521, 7th Sem, EECE. Page 17
Digital Signal Processing
Result:
the result is
x=
Manish Bansal
C07521, 7th Sem, EECE. Page 18
Digital Signal Processing
EXPERIMENT 4(b)
Program Code:
clc;
clear all;
close all;
a=[2,3,4];
b=[1,-1.5,-3.5];
n=5;
b=[b zeros(1,n-1)];
x=deconv(b,a);
disp(x);
stem(x);
x
grid on;
Output Window:
Manish Bansal
C07521, 7th Sem, EECE. Page 19
Digital Signal Processing
Result:
the result is
x=
Manish Bansal
C07521, 7th Sem, EECE. Page 20
Digital Signal Processing
EXPERIMENT 5(a)
Program Code:
clc;
close all;
clear all;
x=input('input the sequence');
y=input('enter the length of the sequence');
z=fft(x,y);
stem(z);
z
Command Window:
z=
Columns 1 through 4
Columns 5 through 8
Manish Bansal
C07521, 7th Sem, EECE. Page 21
Digital Signal Processing
Output Window:
Manish Bansal
C07521, 7th Sem, EECE. Page 22
Digital Signal Processing
EXPERIMENT 5(b)
Program Code:
clc;
close all;
clear all;
x=input('input the sequence');
y=input('enter the length of the sequence');
z=ifft(x,y);
stem(z);
z
Command Window:
z=
Columns 1 through 4
Columns 5 through 8
Manish Bansal
C07521, 7th Sem, EECE. Page 23
Digital Signal Processing
Output Window:
Manish Bansal
C07521, 7th Sem, EECE. Page 24