Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Lab 02

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Experiment No: 02

Experiment Name: Understanding the Basic Signals Using MATLAB.


Objectives:
The objectives of this experiments are
1. To define and plot the signal, x(t) = cos(πt)
2. To define and plot the real and the imaginary part of the signal, y(t)=e3jt in the
time of two periods
3. To plot the signal, x(t)= 3cos(3πt+π/3) in four periods
4. To plot the following two signals together in the same plot, x1(t)=cos(t),
x2(t)=sin(t+π/2)
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
Theory:
MATLAB (an abbreviation of "MATrix LABoratory") is a proprietary multi-
paradigm programming language and numeric computing environment developed
by MathWorks. MATLAB allows matrix manipulations, plotting of functions and
data, implementation of algorithms, creation of user interfaces, and interfacing with
programs written in other languages. Although MATLAB is intended primarily for
numeric computing, an optional toolbox uses the MuPAD symbolic engine allowing
access to symbolic computing abilities. An additional package, Simulink, adds
graphical multi-domain simulation and model-based design for dunamic and
embedded systems.

Software used in lab: MATLAB Simulink

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 :

Fig 2.1: Output curve of x(t) = cos(πt).

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 :

Fig 2.3: Output curve of x(t)= 3cos(3πt+π/3) in four periods.

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 :

Fig 2.5: Output curve of x(t)= AeB1t and y(t)= AeB2t.

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

You might also like