Heaven’s Light is Our Guide
Rajshahi University of Engineering & Technology
Dept. of Electrical & Electronic Engineering
Experiment No: 01
Experiment Name: Introduction to MATLAB
Course Code : EEE3212
Course Title : Power System II Sessional
Submitted By Submitted To
Name: Md. Abdullah Al Mamun Tasnim Sarker Joyeeta
Lecturer,
Roll: 2001044 Department of EEE,
Section: A RUET, Rajshahi
Date of experiment: 04/12/2024
Date of submission: 11/12/2024
1.1 Experiment No.: 01
1.2 Experiment Name: Introduction to MATLAB
1.3 Objectives:
i. To know about MATLAB functions.
ii. To know about different operations.
iii. To learn how to plot an equation.
1.4 Theory:
MATLAB stands for Matrix laboratory. MATLAB is the proprietary software app and
programming language by MathWorks, which facilitates complex data analysis tasks such as
algorithm implementation, interacting with other apps and manipulating a data matrix. This
software allows users to manipulate matrices, run algorithms, design user interfaces, and visualize
multiple functions and data types. It is used for signal processing, image and audio processing,
machine learning, and deep learning.
Among the main tools of MATLAB, some of the most necessary and useful tools are command
window, command history window and workspace browser.
1.5 Different Operation & MATLAB Code:
Arithmetic & logical operation
clc
clear all;
a=5;
b=3;
c=4;
d=4;
%arrithmatic opperation%
S1=a+b
S2=a-b
M1=a*b
D1=a/b
% Logical opertaion%
x=a&&b
y=a||b
z=a~=b
X=xor(a,b)
Output:
Matrix operation:
clc
clear all
A=[1 2 3;2 3 4;5 6 7];
B=[9 8 7;8 7 6;7 6 5];
%Adding%
S1=A+B
%Subtracting%
S2=A-B
%Multiplication%
M=A*B
%Elementwise multiplication%
M=A.*B
%Inverse%
inv(A)
%Special matrix%
zeros(3)
ones(3)
eye(3)
flipud(eye(3))
Output:
Loop
% For loop %
#include <stdio.h>
int main()
{
int i = 0;
for (i = 1; i <= 5; i++)
{
printf( "Hello World\n");
}
return 0;
}
% While loop %
#include <stdio.h>
int main()
{
int i = 2;
while(i < 5)
{
printf( "Hello World\n");
i++;
}
return 0;
}
Output
Plot:
clc
clear all;
t=0:0.01:1;
y=sin(2*pi*2*t)
plot(t,y)
Fig.1.1:Plotting sine wave
Subplot
clc
clear all;
t=0:0.01:1;
y1=sin(2*pi*2*t)
y2=cos(2*pi*2*t)
subplot(2,1,1)
plot(t,y1)
subplot(2,1,2)
plot(t,y2)
Fig.1.2: Plotting sine and Cosine wave
Plotting different graphs on same figure
clc
clear all;
t=0:0.01:1;
y1=sin(2*pi*2*t)
y2=cos(2*pi*2*t)
plot(t,y1)
hold on
plot(t,y2)
Fig.1.3: Plotting sine and Cosine wave in same figure
1.6 Discussion and Conclusion: In this experiment, I was introduced to MATLAB basic
functions. I got to learn how to plot an equation and subplot two equations in the same figure. I
also learnt arithmetic operation, logical operation, loop function in MATLAB. Addition,
subtraction, multiplication and inversion of matrix were also introduced in this experiment. All the
necessary tools and their functions were observed. So, the objectives of this experiment were
accomplished successfully.