Matlab Practical Dewang Joshi
Matlab Practical Dewang Joshi
DEPARTMENT OF MATHEMATICS
LAB REPORT
Submitted By
Name: DEWANG JOSHI
Registration No.: 21BMAN013
Submitted to
Dr. Gaurishankar Paliwal
LIST OF EXPERIMENTS
1 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
g=
4.8627
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
r=
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
e =
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 *
t =
15
p =
1 2
3 4
u =
-2
v =
-2.0000 1.0000
1.5000 -0.5000
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
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 =
3 6 9
F =
32
G =
-3 6 -3
H =
14
I =
3.7417
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 =
y =
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)
plot(x,y)
Output:
Input:
syms x y
x=0:0.1:10
y=exp(x)
plot(x,y)
Output:
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)
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:
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: