In Lab Exercise
In Lab Exercise
%%%ques1
%a
figure
t=-2:.01:2
for i=1:length(t)
if (t(i)==0)
del(i)=Inf
else del(i)=0
end
end
%subplot(2,4,1);
plot(t,del)
ylabel('del(t)');
xlabel('t');
%b
figure
t=-2:0.01:2;
u=1.*(t>=0)+0.*(t<0);
%subplot(2,4,2);
plot(t,u)
ylabel('u(t)');
xlabel('t');
%c
figure
t=-2:5
for i=1:length(t)
if t(i)<=0
r(i)=0;
else
r(i)=t(i);
end
end
%subplot(2,4,3);
plot(t,r)
ylabel('r(t)');
xlabel('t');
%d
figure
f=200;
t=-1:0.1:1;
y=3*sin(2*pi*f.*t);
%subplot(2,4,4);
plot(t,y)
ylabel('3sin(t)');
xlabel('t');
%e
figure
a=.5;
a1=1.5;
t=-4:.5:4;
y1=exp(-a.*t);
subplot(2,1,1);
plot(t,y1)
ylabel('exp(-.5t)');
xlabel('t');
y2=exp(-a1.*t);
subplot(2,1,2);
plot(t,y2)
ylabel('exp(-1.5t)');
xlabel('t');
%f
figure
t=-2:0.01:2;
rect=1.*(t>=-0.5)-1.*(t>=0.5)+0.*(t<-0.5);
%subplot(2,4,7);
plot(t,rect)
ylabel('rect(t)');
xlabel('t');
%g
figure
t=-1:0.1:10;
res=sin(t)./t;
%subplot(2,4,8);
plot(t,res)
ylabel('sinc(t)');
xlabel('t');
%%%ques2
%a
figure;
t=-2:2
for i=1:length(t)
if (t(i)==0)
del1(i)=Inf;
else del1(i)=0;
end
end
subplot(3,1,1);
stem(t,del1)
ylabel('del(n)');
xlabel('n');
%b
t=-2:0.01:2;
u1=1.*(t>=0)+0.*(t<0);
subplot(3,2,1);
plot(t,u1)
ylabel('u(n)');
xlabel('n');
%c
t=-2:5;
for i=1:length(t)
if t(i)<=0
r1(i)=0;
else
r1(i)=t(i);
end
end
subplot(3,1,3);
stem(t,r1)
ylabel('r(n)');
xlabel('n');
%d
figure;
f=200;
t=-1:0.1:1;
y1=3*sin(2*pi*f.*t);
subplot(3,1,1);
stem(t,y1)
ylabel('3sin(n)');
xlabel('n');
%e
a=.5;
a1=1.5;
t=-4:4;
y11=exp(-a.*t);
subplot(3,1,2);
plot(t,y11)
ylabel('exp(-.5t)');
xlabel('n');
y21=exp(-a1.*t);
subplot(3,1,3);
plot(t,y21)
ylabel('exp(-1.5t)');
xlabel('n');
%f
figure;
t=-2:0.01:2;
rect1=1.*(t>=-0.5)-1.*(t>=0.5)+0.*(t<-0.5);
subplot(2,1,1);
plot(t,rect1)
ylabel('rect(n)');
xlabel('n');
%g
t=-1:10;
res1=sin(pi.*t)./(pi.*t);
subplot(2,1,2);
stem(t,res1)
ylabel('sinc(n)');
xlabel('n');