Lab 02
Lab 02
Lab 02
Page 1 of 7
Lab Tasks:
Lab Tasks 1: Define and plot the signal, x(t) = cos(πt).
Code:
clc;
clear all;
close all;
t=0:0.005:20;
x=cos(pi*t);
plot(t,x,'g')
title('Cosine Wave')
xlabel('Time')
ylabel('Amplitude')
Output :
Page 2 of 7
Lab Tasks 2: To define and plot the real and the imaginary part of the signal,
y(t)=e3jt in the time of two periods.
We know, y(t)=e3jt = cos(3t)+jsin(3t)
Here, real part is cos(3t) and imaginary part is sin(3t).
Code:
clc;
w=3;
T=(2*pi)/w;
t = 0:0.001:2*T;
x = cos(3*t);
y = sin(3*t);
subplot (2,1,1);
plot(x,'b');
title('Real part: cos(3t)')
xlabel('Time')
ylabel('Amplitude')
subplot (2,1,2);
plot(y,'g');
title('Imaginary part: sin(3t)')
xlabel('Time')
ylabel('Amplitude')
Output :
Fig 2.2: Output curve of real and the imaginary part of the signal, y(t)=e3jt.
Page 3 of 7
Lab Tasks 3: Plot the signal, x(t)= 3cos(3πt+π/3) in four periods.
Code:
clc;
clear all;
close all;
w=(3*pi);
T=(2*pi)/w;
t=0:0.005:4*T;
x=3*cos(3*pi*t+pi/3);
plot(t,x,'g')
title('Cosine Wave')
xlabel('Time')
ylabel('Amplitude')
Output :
Page 4 of 7
Lab Tasks 4: Plot the following two signals together in the same plot, x1(t)=cos(t),
x2(t)=sin(t+π/2).
Code:
clc;
t = 0:0.001:4*pi;
x1 = cos(t);
subplot (3,1,1);
plot(x1,'b');
title('Cosine Wave')
xlabel('Time')
ylabel('Amplitude')
x2 = sin(t+pi/2);
subplot (3,1,2);
plot(x2,'g');
title('Sine Wave')
xlabel('Time')
ylabel('Amplitude')
subplot (3,1,3);
plot(x1,'b');
hold on
phi=pi/2;
plot(x2,'g');
title('Both Cosine & Sine Wave')
xlabel('Time')
ylabel('Amplitude')
Output :
Fig 2.4: Output curve of x1(t)=cos(t) and x2(t)=sin(t+π/2) and both togather.
Page 5 of 7
Lab Tasks 5: To plot the Signal x(t)= AeB1t and y(t)= AeB2t in the time interval –T<
t< T, where A= Roll Number, B1=A/100, B2=-A/100 and T=A/2.
Code:
clc;
clear all;
close all;
A=6;
B1=A/100;
B2=-B1;
T=A/2;
t=-T:0.01:T;
x=A*exp(B1*t)
y=A*exp(B2*t);
subplot(3,1,1);
plot(t,x,'b');
title('x(t)= Ae^B1t')
xlabel('Time')
ylabel('Amplitude')
subplot(3,1,2);
plot(t,y,'g');
title('y(t)= Ae^B2t')
xlabel('Time')
ylabel('Amplitude')
subplot(3,1,3);
plot(t,x,'b');
hold on
plot(t,y,'g');
title('x(t)= Ae^B1t and y(t)= Ae^B2t togather')
xlabel('Time')
ylabel('Amplitude')
Page 6 of 7
Output :
Conclusion: In this experiment we defined and plotted the signal, x(t) = cos(πt).
We defined and plotted the real and the imaginary part of the signal, y(t)=e3jt in the
time of two periods. We plotted the signal, x(t)= 3cos(3πt+π/3) in four periods. We
plotted the following two signals together in the same plot, x1(t)=cos(t),
x2(t)=sin(t+π/2). We plotted the Signal x(t)= AeB1t and y(t)= AeB2t in the time
interval –T< t< T, where A= my roll number (6), B1=A/100, B2=-A/100 and T=A/2.
All the objectives of the experiment are achieved. The experiment is successfully
done.
Page 7 of 7