0% found this document useful (0 votes)
9 views16 pages

Matlab Practical Dewang Joshi

This document is a MATLAB practical lab report submitted by Dewang Joshi for a B.Sc. Mathematics Hons. course. It includes a list of experiments covering basics of MATLAB, matrix and vector operations, and plotting techniques. Each experiment outlines objectives, source code, and expected outputs for various MATLAB functionalities.

Uploaded by

ariyaankhan917
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)
9 views16 pages

Matlab Practical Dewang Joshi

This document is a MATLAB practical lab report submitted by Dewang Joshi for a B.Sc. Mathematics Hons. course. It includes a list of experiments covering basics of MATLAB, matrix and vector operations, and plotting techniques. Each experiment outlines objectives, source code, and expected outputs for various MATLAB functionalities.

Uploaded by

ariyaankhan917
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/ 16

lOMoARcPSD|51879515

Matlab Practical Dewang Joshi

B.Tech (JECRC University)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by sanidul islam ([email protected])
lOMoARcPSD|51879515

DEPARTMENT OF MATHEMATICS

LAB REPORT

Academic Year: 2022-23 EVEN SEMESTER

Program : BSC MATHEMATICS HONS.


Semester : 4
Course Code : BMA005C
Course Title : MATLAB 1

Submitted By
Name: DEWANG JOSHI
Registration No.: 21BMAN013

Submitted to
Dr. Gaurishankar Paliwal

Downloaded by sanidul islam ([email protected])


lOMoARcPSD|51879515

LIST OF EXPERIMENTS

Course Code: BMA005C


Course Title: MATLAB 1

Exp. No. Title

1 Basics of MATLAB

2 Matrix construction and operations

3 Vector representation and operations

4 Plot of the curve

5 Plot of two curves

Downloaded by sanidul islam ([email protected])


lOMoARcPSD|51879515

Exp. No. - 1 Basics of MATLAB.

Objective - This experiment aims to introduce the basics of MATLAB.

Source Code -
● Creating variables, arithmetic, and trigonometric operations.

>>a=1

a=

>>b=9

b=

>>c=a+b

c=

10

>>e=a*b

e=

>>d=cos(a)

d=

0.5403

>>f=sin(b)

f=

0.4121

>>g=d*e;
>>g

Downloaded by sanidul islam ([email protected])


lOMoARcPSD|51879515

g=

4.8627

Exp. No. - 2 Matrix construction and operations

Objective - The objective of this experiment is to familiarize participants with matrix


construction and operations in MATLAB, enabling them to manipulate matrices, perform
mathematical functions, and apply matrix-based algorithms efficiently.

Source Code -
In the Edit window:

Input:
a=[a b c d]
b=[1 2 3;4 5 6;7 8 9]
z=zeros(3,3)
o=ones(2,3)
r=rand(3)
i=eye(4)

Output:
a=
1.0000 9.0000 10.0000 0.5403

b=

1 2 3
4 5 6
7 8 9

z=

0 0 0
0 0 0
0 0 0

o=

1 1 1
1 1 1

Downloaded by sanidul islam ([email protected])


lOMoARcPSD|51879515

r=

0.8147 0.9134 0.2785


0.9058 0.6324 0.5469
0.1270 0.0975 0.9575

i=

1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1

Input:
a=[2 4 6;1 3 5; 8 9 10]
b=[1 4 9;16 25 36;49 64 81]
c=a+b
d=a-b
e=a*b

Output:

a =

2 4 6
1 3 5
8 9 10

b =

1 4 9
16 25 36
49 64 81

c =

3 8 15
17 28 41
57 73 91

d =

1 0 -3

Downloaded by sanidul islam ([email protected])


lOMoARcPSD|51879515

-15 -22 -31


-41 -55 -71

e =

360 492 648


294 399 522
642 897 1206

Input:
y=[1 2 3;4 5 6;7 8 9]
i= y^(-1)
t=trace(y)
p=[1 2;3 4]
u=det(p)
v=inv(p)
Output:

y =

1 2 3
4 5 6
7 8 9

i =

1.0e+16 *

-0.4504 0.9007 -0.4504


0.9007 -1.8014 0.9007
-0.4504 0.9007 -0.4504

t =

15

p =

1 2
3 4

u =

-2

v =

-2.0000 1.0000

Downloaded by sanidul islam ([email protected])


lOMoARcPSD|51879515

1.5000 -0.5000

● To solve linear equations by matrix


Example: 2x-y+3z=1
x+y+z=2
3x+2y+z=3
Input:
syms x y z
X=[x;y;z]
S=[2 -1 3;1 1 1;3 2 1]
T=[1;2;3]
X=linsolve(S,T)
OR
U=(S^(-1))*T

Output:

X =

x
y
z

S =

2 -1 3
1 1 1
3 2 1

T =

1
2
3

X =

-0.1429
1.2857
0.8571

U =

-0.1429
1.2857
0.8571

Downloaded by sanidul islam ([email protected])


lOMoARcPSD|51879515

Exp. No. - 3 Vector representation and operations

Objective - The objective of this experiment is to introduce participants to vector


representation and its operations in MATLAB, enabling them to manipulate vectors, perform
mathematical functions, and utilize vector-based algorithms effectively.

Source Code -
In the Edit window:
Input:
A=[1 2 3]
B=[4 5 6]
C=A+B
D=A-B
E=3*A
F=dot(A,B)
G=cross(A,B)
H=dot(A,A)
I=sqrt(H)

Output:

A =

1 2 3

B =

4 5 6

C =

5 7 9

D =

-3 -3 -3

E =

Downloaded by sanidul islam ([email protected])


lOMoARcPSD|51879515

3 6 9

F =

32

G =

-3 6 -3

H =

14

I =

3.7417

Downloaded by sanidul islam ([email protected])


lOMoARcPSD|51879515

Exp. No. - 4 Plot of the curve

Objective - The objective of this experiment is to learn the skills necessary to plot
curves in MATLAB, allowing them to visualize and analyze data effectively using various
plotting techniques.

Source Code -
In the Edit window:
Input:
syms x y
x=0:0.1:1
y=x.^2
plot(x,y)

Output:

x =

0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000


0.7000 0.8000 0.9000 1.0000

y =

0 0.0100 0.0400 0.0900 0.1600 0.2500 0.3600


0.4900 0.6400 0.8100 1.0000

Downloaded by sanidul islam ([email protected])


lOMoARcPSD|51879515

Input:
syms x y
x=0:0.01:10
y=sin(x)
plot(x,y)

Output:

Input:
syms x y
x=0:0.01:10
y=log(x)

Downloaded by sanidul islam ([email protected])


lOMoARcPSD|51879515

plot(x,y)

Output:

Input:
syms x y
x=0:0.1:10
y=exp(x)
plot(x,y)

Output:

Downloaded by sanidul islam ([email protected])


lOMoARcPSD|51879515

Exp. No. - 5 Plot of two curves

Objective - The objective of this experiment is to learn to plot two curves in MATLAB,
facilitating the visualization and comparison of data by utilizing the plotting capabilities to
overlay multiple curves on a single graph.

Source Code -
In the Edit window:
Input:
syms x y z
x = 0:0.1:10;
y = sin(x);
z = cos(x);
plot(x, y)
hold on
plot(x, z)

Downloaded by sanidul islam ([email protected])


lOMoARcPSD|51879515

Output:

Input:
syms x y z
x = 0:0.1:10;
y = sin(x);
z = log(x);
plot(x, y)
hold on
plot(x, z)

Output:

Downloaded by sanidul islam ([email protected])


lOMoARcPSD|51879515

Input:
syms x y z
x = 0:0.1:10;
y = exp(x);
z = log(x);
plot(x, y)
hold on
plot(x, z)

Output:

Downloaded by sanidul islam ([email protected])

You might also like