You are on page 1of 8

Name: Dev Raj

Roll No.: 3583


Experiment 2

2.1 Plot the following discrete time signals for n=-10 to 12.
Program
clear
clf
n=-10:1:12;
for i=1:length(n)
y1(i)=5*n(i)*n(i)+3*n(i)
end
for i=1:length(n)
y2(i)=sin(%pi*n(i)/2)+cos(%pi*n(i)/4)
end
a=-3
for i=1:length(n)
y3(i)=a^n(i)
end
subplot(4,2,1)
plot2d3(n',y1);
title('y1=5*n*n+3*n')
subplot(4,2,2)
plot2d3(n,y2);
title('y2=sin(%pi*n/2)+cos(%pi*n/4)')
subplot(4,2,3)
plot2d3(n,y3);
title('y3=a^n a=-3')
a=3
for i=1:length(n)
y3(i)=a^n(i)
end
subplot(4,2,4)
plot2d3(n,y3);
title('y3=a^n a=3')
a=1
for i=1:length(n)
y3(i)=a^n(i)
end
subplot(4,2,5)
plot2d3(n,y3);
title('y3=a^n a=1')
a=-1/3
for i=1:length(n)
y3(i)=a^n(i)
end
subplot(4,2,6)
plot2d3(n,y3);
title('y3=a^n a=-1/3')
a=1/3
for i=1:length(n)
y3(i)=a^n(i)
end
subplot(4,2,7)
plot2d3(n,y3);
title('y3=a^n a=1/3')

Output
2.2 Plot the following discrete time signals for n=-3 to L+2.
Program
clc
clf
clear
l=5
n=-3:1:l+2
a=2
for i=1:length(n)
if n>=0
then
u(i)=1 else
u(i)=0
end
end
subplot(3,2,1)
plot2d3(n,u)
a=1
b=2
for i=1:length(n)
if (n-b)>=0 then
u(i)=a*1 else
u(i)=0
end
end
subplot(3,2,2)
plot2d3(n,u)
a=3
for i=1:length(n)
if n==0 then
d(i)=1 else
d(i)=0
end end
subplot(3,2,3)
plot2d3(n,d)
a=1
b=3
for i=1:length(n)
if n+b==0 then
d(i)=1 else
d(i)=0
end
end
subplot(3,2,4)
plot2d3(n,d)
subplot(3,2,5)
plot2d3(n,3*sinc(n))
Output

2.3 Plot the following discrete time signals for n -5 to 5.


Program
clc
clf
clear
n=-5:1:5
for i=1:length(n)
if n(i)>=3 then y1(i)=2
elseif n(i)<(-3) then y1(i)=-1;
else y1(i)=n(i)
end
end
subplot(2,2,1)
plot2d3(n',y1)
title('y1')
for i=1:length(n)
if n(i)>-2 then y2(i)=sin((0.2)*%pi*n(i))
else y2(i)=1
end
end
subplot(2,2,2)
plot2d3(n',y2)
title('y2')
for i=1:length(n)
if n(i)>1 then y3(i)=n(i)
else y3(i)=2
end
end
subplot(2,2,3)
plot2d3(n',y3)
title ('y3')

Output
2.4 Plot the Following discrete time signals for n=- 10 to 10.
Program
clear
clf
clc
n=-10:10
j=sqrt(-1)
for i=1:length(n)
x1(i)= exp(j*(0.5)*n(i))+exp(j*(0.7)*n(i))
end
subplot(5,3,1)
plot2d3(n,x1)
title('x1= exp(j*(0.5)*n)+exp(j*(0.7)*n)')
for i=1:length(n)
x2(i)=5*exp((0.2)*n(i))
end
subplot(5,3,2)
plot2d3(n,x2)
title('x2=5*exp((0.2)*n)')
for i=1:length(n)
x3(i)=3*exp(j*(0.2)*n(i))
end
subplot(5,3,3)
plot2d3(n,x3)
title('x3=3*exp(j*(0.2)*n)')
a=5
for i=1:length(n)
x4(i)=a^n(i)
end
subplot(5,3,4)
plot2d3(n,x4)
title(' x4=a^n')
a=-3
for i=1:length(n)
x5(i)=(a^n(i))*exp(j*2*a*n(i))
end
subplot(5,3,5)
plot2d3(n,x5)
title('x5=(a^n)*exp(j*2*a*n) a=-3')
a=3
for i=1:length(n)
x5(i)=(a^n(i))*exp(j*2*a*n(i))
end
subplot(5,3,6)
plot2d3(n,x5)
title('x5=(a^n)*exp(j*2*a*n) a=3')
a=1
for i=1:length(n)
x5(i)=(a^n(i))*exp(j*2*a*n(i))
end
subplot(5,3,7)
plot2d3(n,x5)
title('x5=(a^n)*exp(j*2*a*n) a=1')
a=-1/3
for i=1:length(n)
x5(i)=(a^n(i))*exp(j*2*a*n(i))
end
subplot(5,3,8)
plot2d3(n,x5)
title('x5=(a^n)*exp(j*2*a*n) a=-1/3')
a=1/3
for i=1:length(n)
x5(i)=(a^n(i))*exp(j*2*a*n(i))
end
subplot(5,3,9)
plot2d3(n,x5)
title('x5=(a^n)*exp(j*2*a*n) a=1/3')
b=-3
for i=1:length(n)
x6(i)=3^(-b*n(i))*exp(j*b*n(i))
end
subplot(5,3,10)
plot2d3(n,x6)
title(' x6=3^(-b*n)*exp(j*b*n) b=-3')
b=3
for i=1:length(n)
x6(i)=3^(-b*n(i))*exp(j*b*n(i))
end
subplot(5,3,11)
plot2d3(n,x6)
title(' x6=3^(-b*n)*exp(j*b*n) b=3')
b=1
for i=1:length(n)
x6(i)=3^(-b*n(i))*exp(j*b*n(i))
end
subplot(5,3,12)
plot2d3(n,x6)
title(' x6=3^(-b*n)*exp(j*b*n) b=1')
b=-1/3
for i=1:length(n) x6(i)=3^(-b*n(i))*exp(j*b*n(i))
end
subplot(5,3,13)
plot2d3(n,x6)
title('x6=3^(-b*n)*exp(j*b*n) b=-1/3')
b=1/3
for i=1:length(n)
x6(i)=3^(-b*n(i))*exp(j*b*n(i))
end
subplot(5,3,14)
plot2d3(n,x6)
title('x6=3^(-b*n)*exp(j*b*n) b=1/3')

Output

You might also like