1-Introduction to MATLAB
1-Introduction to MATLAB
Marks Obtained
Group Member Group Member Group Member
1 2 3
NAME DUA NASEEM
REGISTRATION # 220701014
LAB REPORT MARKS
PERFORMANCE MARKS
TOTAL MARKS
________________________________________________________________________
Experiment # 01 Page 1 of 9
Control Systems Lab
_________________________________________________________________________
Exercise 1:
CODE:
a) m=magic(6)
m4=m(4,:)
disp(m4)
OUTPUT:
CODE:
b) x = [0:0.1:1.1]
y = [10:21]
mul=x.*y
div=y./x
disp(mul)
disp(div)
OUTPUT:
________________________________________________________________________
Experiment # 01 Page 2 of 9
Control Systems Lab
_________________________________________________________________________
CODE:
c) r=randi([-8,9],4,5)
disp(r)
OUTPUT:
Exercise 2:
x=pi/2:pi/10:2*pi;
y=sin(x);
z=cos(x);
________________________________________________________________________
Experiment # 01 Page 3 of 9
Control Systems Lab
_________________________________________________________________________
CODE:
title("cos curve")
xlabel("angle")
ylabel("cosx")
ax = gca
grid on
ax.GridLineStyle = '--'
OUTPUT:
________________________________________________________________________
Experiment # 01 Page 4 of 9
Control Systems Lab
_________________________________________________________________________
sine curve
1
0.5
sinx
0
-0.5
-1
1.5 2 2.5 3 3.5 4 4.5 5 5.5 6 6.5
angle
cos curve
1
0.5
cosx
-0.5
-1
1.5 2 2.5 3 3.5 4 4.5 5 5.5 6 6.5
angle
Exercise 3:
[ ]
1.2 3.04 7.3 3.2
−1 −12 1.2 5
A= 2.7 1 −2 4 ,
6.6 4.51 0 1
−3 −2.2 1 6
[]
1.3
−1
B=
2.5
1.6
CODE:
A=[1.2,3.04,7.3,3.2;
-1,-12,1.2,5;
2.7,1,-2,4;
________________________________________________________________________
Experiment # 01 Page 5 of 9
Control Systems Lab
_________________________________________________________________________
6.6,4.51,0,1;
-3,-2.2,1,6]
B=[1.3;-1;2.5;1.6]
size(A)
mult=A*B
disp(mult)
A(2:4,[1,3])
OUTPUT:
________________________________________________________________________
Experiment # 01 Page 6 of 9
Control Systems Lab
_________________________________________________________________________
Exercise 4:
𝑧 = 𝑒−2𝑡 cos(3𝑡 + 1) − 𝜋 ≤ 𝑡 ≤ 5𝜋
________________________________________________________________________
Experiment # 01 Page 7 of 9
Control Systems Lab
_________________________________________________________________________
CODE:
OUTPUT:
-2t
Graph of z = e * cos(3t + 1)
200
150
100
50
-50
z
-100
-150
-200
-250
-300
-5 0 5 10 15 20
t
b. The deflection of a cantilever beam is the distance its end moves in response to a
force applied at the end. The following table gives the deflection 𝑥 that was
produced in a particular beam by the given applied force 𝑓. Plot the graph:
Force 𝑓 (pound) 0 100 200 300 400 500 600 700 800
Deflection 𝑥 0 0.09 0.18 0.28 0.37 0.46 0.55 0.65 0.74
(inches)
CODE:
________________________________________________________________________
Experiment # 01 Page 8 of 9
Control Systems Lab
_________________________________________________________________________
OUTPUT:
0.7
0.6
Deflection (inches)
0.5
0.4
0.3
0.2
0.1
0
0 100 200 300 400 500 600 700 800
Force (pounds)
________________________________________________________________________
Experiment # 01 Page 9 of 9
Control Systems Lab