Assignemt Matlab
Assignemt Matlab
t=[-10:0.1:10];
x=inline('5.*sin(2.*pi.*t).*exp(-0.4.*t)','t');
plot(t,x(t),"linewidth",1.5);
title('Exponentially Damped Sinusoidal Signal');
xlabel('t(time)')
ylabel('x(t)')
% QUESTION 2
t=[-5:0.01:5];
u=inline('heaviside(t)','t');
plot(t,u(t),'linewidth',2);
xlabel('t(time)')
ylabel('u(t)')
axis([-5 5 -2 2])
title('Unit Step Function')
%QUESTION 3
rect=inline('(t>=-5) & (t<5)','t');
t=[-10:0.1:10];
plot(t,rect(t),'linewidth',2)
xlabel('t(time)')
ylabel('rect(t)')
title('Rectangular Pulse function')
axis([-10 10 -2 2])
% Question 4a
tx=[0:0.01:4];
x=ones(1,length(tx));
th=[0:0.01:4];
h=ones(1,length(th));
[y]=conv(x,h);
plot(y);
xlabel('Time')
ylabel('Amplitude');
axis([0 8 0 4]);
Continuos-time convolution
400
350
300
250
Amplitude
200
150
100
50
0
0 100 200 300 400 500 600 700 800
Time
% Question 4b
tx=[0:0.01:3];
tx1=[0:0.01:1];
x=[zeros(1,length(tx1)) ones(1,(length(tx)-length(tx1)))];
th1=[-1:0.01:1];
th2=[1.01:0.01:3];
h=[ones(1,length(th1)) -1*ones(1,length(th2))];
th=[-1:0.01:3];
[y]=conv(x,h);
figure;
plot(y);
xlabel('Time')
ylabel('Amplitude');
axis([0 6 -2 2])
title('Continuos-time convolution')
Continuos-time convolution
200
150
100
50
Amplitude
-50
-100
-150
-200
0 100 200 300 400 500 600 700
Time
% QUESTION 5
tx=[0:0.01:5];
tx1=[0:0.01:3];
x=[zeros(1,length(tx1)) ones(1,(length(tx)- length(tx1)))];
th=[0:0.01:5];
h =(3)* exp(-3*th);
[y]=conv(x,h);
figure;
plot(y);
xlabel('Time')
ylabel('Amplitude');
NARH JOHN