0% found this document useful (0 votes)
13 views11 pages

Poc Lab 1

Uploaded by

mushfiquelabib
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views11 pages

Poc Lab 1

Uploaded by

mushfiquelabib
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

American International University - Bangladesh

Department of Electrical and Electronic Engineering


EEE 3215: PRINCIPLES OF COMMUNICATION

Semester: Fall 2024-2025 Section: C

Experiment Number: 01.

Title: Introduction to MATLAB.


Submitted to-

DR. SHUVRA MONDAL


ASSISTANT PROFESSOR, Dept. of EEE
Faculty of Engineering, AIUB

Submitted by-
Group Number: 03

Group Members-
SL NAME ID

11 DAIYAN, F.M. MAHIR 22-49716-3

12 MITU, RIFAT ARA 22-47744-2

13 AKTER,AIRIN 22-46334-1

14 LABIB, MUSHFIQUE REDWAN 22-47132-1

15 ZAMAN, MD. SHAHRIAR 22-47754-2

Submission Date:28/10/2024

Faculty of Engineering, AIUB Dept. of Electrical & Electronics Engineering (EEE)


Experimental finding (Commands MATLAB)
Entering Matrices and Addressing the Elements
MATLAB drive is the name of the directory where the script is saved.untitled.m is the
name of the script file. When we run the script, MATLAB executes the code and displays
the result in the Command Window.
Command: >> A=[1 2 3; 8 6 4; 3 6 9].
OUTPUT

Explanation: This line of code creates a 3×3 matrix named A.The numbers within the brackets
represent the elements of the matrix.The semicolon ; separates the rows of the matrix &
space(<>) separates the columns of the matrix.
Command: >> A(1,3)+A(2,1)+A(3,2).
OUTPUT

Explanation: This line of code performs an operation on the elements of the matrix A that
was defined in the previous script.A(1,3) refers to the element in the first row and third
column of the matrix.A(2,1) refers to the element in the second row and first column of the
matrix.A(3,2) refers to the element in the third row and second column of the matrix.The
+ operator is used to add these elements together.
Command: >> A(2:3.1:2)
OUTPUT

Explanation: A(2:3, 1:2): This command extracts a submatrix from matrix A.2:3 specifies
that rows 2 to 3 of matrix A are selected.1:2 specifies that columns 1 to 2 of matrix A are
selected.
Command: >> A(1,1:2)
OUTPUT
Explanation: A(1, 1:2): This command extracts elements from the 1st row of matrix A.1
specifies that the 1st row of matrix A is selected.1:2 specifies that columns 1 to 2 of matrix
A are selected.
Command:>> A(:,2)
OUTPUT

Explanation: This line of code extracts the second column of the matrix A.The A(:,2)
syntax means "all rows of A, and the second column.". The output shows the contents of
the second column of the matrix A.
Command:>> linspace (0,pi,101)
OUTPUT
Explanation: This line of code creates a vector named x.The linspace function generates
evenly spaced numbers over a specified interval.In this case, it generates 101 numbers
between 0 and pi (approximately 3.14159).
Command:>> v= (10:-2:0)
OUTPUT

Explanation: This line of code creates a vector named v.The expression (10:-2:0)
generates a sequence of numbers starting from 10,decreasing by 2 in each step, and ending
at 0.
Command:>> B= zeros(3,4)
OUTPUT
Explanation: This line of code creates a 3×4 matrix named B.The zeros function creates
a matrix filled with zeros.The arguments (3,4) specify the dimensions of the matrix,3 rows
and 4 columns.
Command:>> C=ones(2,5)*6
OUTPUT

Explanation: This line of code creates a 2x5 matrix named C.The ones(2,5) function
creates a 2×5 matrix filled with ones.The *6 multiplies each element of the matrix by 6.
Command:>> D= rand(1,5)
OUTPUT

Explanation: D =: This assigns the generated random numbers to a variable named


D.rand(1,5): This function generates a 1x5 matrix (a row vector) with 5 random numbers.
The numbers are uniformly distributed between 0 and 1.
Command:>> E=randn(3,3)
OUTPUT

Explanation: This line of code creates a 3x3 matrix named E.The randn function generates
random numbers from a standard normal distribution (mean = 0, standard deviation =
1).The arguments (3,3) specify the dimensions of the matrix,3 rows and 3 columns.
Command:>> A(2,:)=[]
OUTPUT

Explanation: This line of code deletes the second row of the matrix A.The A(2,:) part
specifies the second row of the matrix.Assigning an empty array [] to this row effectively
removes it.
Command:>> x=0:pi/100:2*pi;
>> y=sin(x);
>> plot(x,y)
OUTPUT

Command: >> xlabel(‘x’);


>> ylabel(‘y’);
>> title(‘y=sin(x)’)
OUTPUT

Explanation: x = 0:pi/100:2*pi;: This line creates a vector x containing 101 evenly spaced
values between 0 and 2π.y = sin(x);: This line calculates the sine of each value in the x
vector and stores the results in the y vector.plot(x,y): This line plots the values in y against
the corresponding values in x, creating a sine wave graph.xlabel('x'): This line labels the x-
axis of the plot as "x".ylabel('y'): This line labels the y-axis of the plot as
"y".title('y=sin(x)'): This line adds a title to the plot, indicating that it represents the
function y = sin(x).
Command: >> x1 = 0:pi/100:2*pi;
y1 = sin(x1);
y2 = sin(x1 - 0.30);
y3 = sin(x1 - 0.60);
plot(x1,y1,’g:*’)
hold on
plot(x1,y2,’r:+’)
hold on
plot (x1,y3,’b:o’)
OUTPUT

Explanation: x1 = 0:pi/100:2*pi;: This line creates a vector x1 containing 101 evenly


spaced values between 0 and 2π.y1 = sin(x1);: This line calculates the sine of each value
in the x1 vector and stores the results in the y1 vector.y2 = sin(x1 - 0.38);: This line
calculates the sine of each value in the x1 vector shifted by 0.38 units to the right, and
stores the results in the y2 vector.y3 = sin(x1 - 0.60);: This line calculates the sine of each
value in the x1 vector shifted by 0.60 units to the right, and stores the results in the y3
vector.plot(x1,y1,'g-*'): This line plots the values in y1 against the corresponding values in
x1, creating a green sine wave graph with green stars as markers.hold on: This command
ensures that the next plot will be superimposed on the existing plot.plot(x1,y2,'r:+'): This
line plots the values in y2 against the corresponding values in x1, creating a red sine wave
graph with red plus signs as markers.hold on: This command ensures that the next plot will
be superimposed on the existing plots.plot(x1,y3,'b:o'): This line plots the values in y3
against the corresponding values in x1, creating a blue sine wave graph with blue circles
as markers.
Command: >> t= -pi:pi/100:pi;
s=cos(t);
plot(t,s)
axis([-pi pi -1 1])
xlabel('-\pi\leq t\leq\pi')
ylabel('cos(t)')
title('the cosine function')
text(-2,-0.5,'This is a note at position (-2,-0.5)')
OUTPUT

Explanation: t = -pi:pi/100:pi;: This line creates a vector t containing 201 evenly spaced
values between -π and π.s = cos(t);: This line calculates the cosine of each value in the t
vector and stores the results in the s vector.plot(t,s): This line plots the values in s against
the corresponding values in t, creating a cosine wave graph.axis([-pi pi -1 1]): This line
sets the x-axis limits to -π and π, and the y-axis limits to -1 and 1.xlabel('\pi \leq t \leq \pi'):
This line labels the x-axis of the plot with the expression "π ≤ t ≤ π".ylabel('cos(t)'): This
line labels the y-axis of the plot as "cos(t)".title('the cosine function'): This line adds a title
to the plot, indicating that it represents the cosine function.text(-2,-0.5,'This is a note at
position (-2,-0.5)'): This line adds a text annotation to the plot at the specified coordinates,
displaying the text "This is a note at position (-2,-0.5)".
Discussion & Conclusion:

The objectives of the lab experiment were met, and all of the tasks were finished.
Although MATLAB has several advantages over other programs, its efficacy is up for debate. This
creates opportunities for more investigation into possibly useful research.To sum up, this lab
experiment gave a useful overview of the fundamental MATLAB's features and applications. We
obtained real-world experience through experiential learning. Our results show that MATLAB
may be used for this course in an efficient manner. But it's crucial to recognise our limitations .
All things considered, this experience provided a strong basis for further research into MATLAB's
capabilities.

You might also like