You are on page 1of 20

Lab Manual ME 3602 Control System SZABIST

School of Mechatronic Engineering

Laboratory Report
For
ME3602-L Control System

Sixth Semester
Spring 2024

Name: S.M Hamza Zafar

Reg. No: 2045124

Group No.:

Department of Mechatronics Engineering


Lab Manual ME 3602 Control System SZABIST

Lab Rules
1. Students must thoroughly read the assigned work. It will be assumed that they have studied the
assigned work and have understood the majority of the material and technical terms before the start
of the experiments.
2. All the original data have to be recorded in a Report sheet during the laboratory sessions. Data
recording on rough sheets of papers are not allowed. In order to check for the originality of the data,
ball pen or inerasable pen should be used. If correction has to be made, just cross it out. They must
hand over the Report sheet to the demonstrator for their signature after data count.
3. For safety reasons, students are requested not to leave their equipment unattended during the lab.
Session. In the case of special circumstances, please seek the support of the class
teachers/demonstrators
4. All practical contribute to the final results of the sessional course. Thus any absent laboratory session
automatically means lost marks for the final grade. Under special circumstances (supported by
documentary proof), e.g. illness and other reasonable causes a laboratory session may be re-
scheduled upon approval of the head of the department.
5. During the class, students will be continuously assessed by performance test on each and every
experiment.
6. To ensure your fellow students can proceed with their experiments in a degree of comfort and
without undue noise and other disturbances, keep the noise level down and stay in your own
laboratory bench area. Mobile phones should be switched off during the experiments

Front Page:
• Name of the Student
• Student ID No.
• Name of the Department
• Group
• Batch No.
• Date of Allotment
• Date of Performance
• Date of Submission

Inside Page:
Calculations
Relevant formulae should be stated, i.e., only those used to calculate experimental results. Great
care should be exercised in performing simple arithmetic operations and the calculation should be
thoroughly checked. Result
Discussion
Students should write discussion on the overall accuracy of your results and on any systematic errors
in the experiment or agreement/discrepancy with expected values.

Department of Mechatronics Engineering


Lab Manual ME 3602 Control System SZABIST

Index
S. Page
Date Topic Detail Remarks
No No.

Department of Mechatronics Engineering


Lab Manual ME 3602 Control System SZABIST

S. Page
Date Topic Detail Remarks
No No.

Department of Mechatronics Engineering


Lab Manual ME 3602 Control System SZABIST

Experiment # 1
Task 01: To perform following matrix algebra using Matlab.
I. A+B
II. A+C
III. AXB
IV. DXC
V. CXD
VI. A/C

A=> 3x3 matrix (create using ‘randi’ command)

B=> 3x2 matrix

C=>3x3 matrix

D=> 2x2 matrix

Coding:

A=randi (9,3)
b=[4 4;5 5;6 6]
c= randi (6,3)
d=randi (4,2)
ab=a+b
ac=a+c
ba=a*b
dc=d*c
cd=c*d
ca=a/c

Result:

>> randi (9,3)

ans =

4 9 8
9 6 9
8 1 7

>> randi (6,3)

ans =

5 4 1

Department of Mechatronics Engineering


Lab Manual ME 3602 Control System SZABIST

5 2 2
3 5 1

>> randi (4,2)

ans =

1 3
4 2
ac=a+c

ac =

10 10 10
10 10 10
10 10 10

>> dc=d*c

dc =

32 32
77 77
122 122

Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in
the
first matrix matches the number of rows in the second matrix. To perform
elementwise
multiplication, use '.*'.

Related documentation

>> ab=a*b

ab =

32 32
77 77
122 122

>> dc=d*c
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in
the
first matrix matches the number of rows in the second matrix. To perform
elementwise
multiplication, use '.*'.

Department of Mechatronics Engineering


Lab Manual ME 3602 Control System SZABIST

Related documentation

>> cd=c*d
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in
the
first matrix matches the number of rows in the second matrix. To perform
elementwise
multiplication, use '.*'.

Related documentation

>> ca=a/c
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate.
RCOND
= 2.312965e-18.

ca =

-0.3889 2.1111 -2.7222


0.1944 1.9444 -3.1389
0.7778 1.7778 -3.5556

Task 02: To find out inverse of the matrices as mentioned in Q1.

Coding:

tt=inv (a)
tt=inv (b)
tt=inv (c)
tt=inv (d)
Result:

>> tt=inv (a)


Warning: Matrix is close to singular or badly scaled. Results may be inaccurate.
RCOND
= 2.202823e-18.

tt =

1.0e+16 *

0.3153 -0.6305 0.3153


-0.6305 1.2610 -0.6305
0.3153 -0.6305 0.3153

Department of Mechatronics Engineering


Lab Manual ME 3602 Control System SZABIST

>> tt=inv (b)


Error using inv
Matrix must be square.

>> tt=inv (c)


Warning: Matrix is close to singular or badly scaled. Results may be inaccurate.
RCOND
= 3.083953e-18.

tt =

1.0e+15 *

2.2518 -4.5036 2.2518


-4.5036 9.0072 -4.5036
2.2518 -4.5036 2.2518

>> tt=inv (d)


Warning: Matrix is singular to working precision.

tt =

Inf Inf
Inf Inf

Task 03: To find out determinant of the matrices as mentioned in Q1.

Coding:

dd=det(d)
Result:

dd=det(a)

dd =

-9.5162e-16

>> dd=det(b)
Error using det
Matrix must be square.

>> dd=det(c)

dd =

-1.3323e-15

Department of Mechatronics Engineering


Lab Manual ME 3602 Control System SZABIST

>> dd=det(d)

dd =

Department of Mechatronics Engineering


Lab Manual ME 3602 Control System SZABIST

Task 04: To find out transpose of the matrices as mentioned in Q1.

Coding:

t=a'
t=b'
t=c'
t=d'

Result:

t=a'

t=

1 4 7
2 5 8
3 6 9

>> t=b'

t=

4 5 6
4 5 6

>> t=c'

t=

9 6 3
8 5 2
7 4 1

>> t=d'

t=

1 1
1 1

Task 05: Plot a sine wave with different given step size in a single Graph, using hold, grid and
legend command and differentiate respective wave using different styles (‘o’,’+’,’— ‘)

I. 0:1:10
II. 0:0.1:10
III. 0:0.01:10

Coding:

Department of Mechatronics Engineering


Lab Manual ME 3602 Control System SZABIST

t=0:1:10
x=cos (t)
plot (t,x)

u=0:0.5:10
y=cos (u)
plot (u,y)

v=0:0.1:10
z=cos (v)
plot (v,z)

Result:

t=0:1:10
x=cos (t)
plot (t,x)

t=

0 1 2 3 4 5 6 7 8 9 10

x=

Columns 1 through 8

1.0000 0.5403 -0.4161 -0.9900 -0.6536 0.2837 0.9602 0.7539

Columns 9 through 11

-0.1455 -0.9111 -0.8391

>> u=0:0.5:10
y=cos (u)
plot (u,y)

u=

Columns 1 through 8

0 0.5000 1.0000 1.5000 2.0000 2.5000 3.0000 3.5000

Columns 9 through 16

4.0000 4.5000 5.0000 5.5000 6.0000 6.5000 7.0000 7.5000

Columns 17 through 21

Department of Mechatronics Engineering


Lab Manual ME 3602 Control System SZABIST

8.0000 8.5000 9.0000 9.5000 10.0000

y=

Columns 1 through 8

1.0000 0.8776 0.5403 0.0707 -0.4161 -0.8011 -0.9900 -0.9365

Columns 9 through 16

-0.6536 -0.2108 0.2837 0.7087 0.9602 0.9766 0.7539 0.3466

Columns 17 through 21

-0.1455 -0.6020 -0.9111 -0.9972 -0.8391

v=0:0.1:10
z=cos (v)
plot (v,z)

v=

Columns 1 through 8

0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000

Columns 9 through 16

0.8000 0.9000 1.0000 1.1000 1.2000 1.3000 1.4000 1.5000

Columns 17 through 24

1.6000 1.7000 1.8000 1.9000 2.0000 2.1000 2.2000 2.3000

Columns 25 through 32

2.4000 2.5000 2.6000 2.7000 2.8000 2.9000 3.0000 3.1000

Columns 33 through 40

3.2000 3.3000 3.4000 3.5000 3.6000 3.7000 3.8000 3.9000

Columns 41 through 48

4.0000 4.1000 4.2000 4.3000 4.4000 4.5000 4.6000 4.7000

Department of Mechatronics Engineering


Lab Manual ME 3602 Control System SZABIST

Columns 49 through 56

4.8000 4.9000 5.0000 5.1000 5.2000 5.3000 5.4000 5.5000

Columns 57 through 64

5.6000 5.7000 5.8000 5.9000 6.0000 6.1000 6.2000 6.3000

Columns 65 through 72

6.4000 6.5000 6.6000 6.7000 6.8000 6.9000 7.0000 7.1000

Columns 73 through 80

7.2000 7.3000 7.4000 7.5000 7.6000 7.7000 7.8000 7.9000

Columns 81 through 88

8.0000 8.1000 8.2000 8.3000 8.4000 8.5000 8.6000 8.7000

Columns 89 through 96

8.8000 8.9000 9.0000 9.1000 9.2000 9.3000 9.4000 9.5000

Columns 97 through 101

9.6000 9.7000 9.8000 9.9000 10.0000

z=

Columns 1 through 8

1.0000 0.9950 0.9801 0.9553 0.9211 0.8776 0.8253 0.7648

Columns 9 through 16

0.6967 0.6216 0.5403 0.4536 0.3624 0.2675 0.1700 0.0707

Columns 17 through 24

-0.0292 -0.1288 -0.2272 -0.3233 -0.4161 -0.5048 -0.5885 -0.6663

Columns 25 through 32

-0.7374 -0.8011 -0.8569 -0.9041 -0.9422 -0.9710 -0.9900 -0.9991

Columns 33 through 40

Department of Mechatronics Engineering


Lab Manual ME 3602 Control System SZABIST

-0.9983 -0.9875 -0.9668 -0.9365 -0.8968 -0.8481 -0.7910 -0.7259

Columns 41 through 48

-0.6536 -0.5748 -0.4903 -0.4008 -0.3073 -0.2108 -0.1122 -0.0124

Columns 49 through 56

0.0875 0.1865 0.2837 0.3780 0.4685 0.5544 0.6347 0.7087

Columns 57 through 64

0.7756 0.8347 0.8855 0.9275 0.9602 0.9833 0.9965 0.9999

Columns 65 through 72

0.9932 0.9766 0.9502 0.9144 0.8694 0.8157 0.7539 0.6845

Columns 73 through 80

0.6084 0.5261 0.4385 0.3466 0.2513 0.1534 0.0540 -0.0460

Columns 81 through 88

-0.1455 -0.2435 -0.3392 -0.4314 -0.5193 -0.6020 -0.6787 -0.7486

Columns 89 through 96

-0.8111 -0.8654 -0.9111 -0.9477 -0.9748 -0.9922 -0.9997 -0.9972

Columns 97 through 101

-0.9847 -0.9624 -0.9304 -0.8892 -0.8391

Department of Mechatronics Engineering


Lab Manual ME 3602 Control System SZABIST

1
step size of 1
0.8 step size of 0.5
step size of 0.1
0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8

-1
0 1 2 3 4 5 6 7 8 9 10

step size of 1
step size of 0.5
step size of 0.1
-0.5

-0.6

-0.7

-0.8

-0.9

-1
2 2.5 3 3.5 4 4.5

π π
Task 06: Plot a tangent wave using appropriate range (HINT: - to + ).
2 2

Coding:

clf;clear all;clc
x=linspace(-pi/2+0.01,pi/2-0.01);
y=tan(x);

Department of Mechatronics Engineering


Lab Manual ME 3602 Control System SZABIST

plot (x,y);

Result:

100

80

60

40

20

-20

-40

-60

-80

-100
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2

Task 07: Using MATLAB help creates an identity, a unit and a null matrix. (Used dedicated
command)

Coding:

identity=eye(3)
unit=ones(3)
null=zeros(3)

Result:

>> identity=eye(3)
unit=ones(3)
null=zeros(3)

identity =

1 0 0
0 1 0

Department of Mechatronics Engineering


Lab Manual ME 3602 Control System SZABIST

0 0 1

unit =

1 1 1
1 1 1
1 1 1

null =

0 0 0
0 0 0
0 0 0

Department of Mechatronics Engineering


Lab Manual ME 3602 Control System SZABIST

Task 08: Find Eigen value and corresponding vector, trace and rank of the given matrix

[ ] [ ]
2 0 0 6 0 −8
A= −9 −8 −1 B= 1 8 11
0 8 1 0 7 −7

Coding:

a=[2 0 0; -9 -8 -1; 0 8 1]
b=[6 0 -8; 1 8 11; 0 -7 7]
t1=trace(a)
r1=rank(a)
[c1,d1]=eig(a)
t2=trace(b)
r2=rank(b)
[c2,d2]=eig(b)

Result:

>> a=[2 0 0; -9 -8 -1; 0 8 1]


b=[6 0 -8; 1 8 11; 0 -7 7]
t1=trace(a)
r1=rank(a)
[c1,d1]=eig(a)
t2=trace(b)
r2=rank(b)
[c2,d2]=eig(b)

a=

2 0 0
-9 -8 -1
0 8 1

b=

6 0 -8
1 8 11
0 -7 7

t1 =

-5

r1 =

Department of Mechatronics Engineering


Lab Manual ME 3602 Control System SZABIST

c1 =

0 0 0.2408
-0.1240 0.7071 -0.1204
0.9923 -0.7071 -0.9631

d1 =

0 0 0
0 -7 0
0 0 2

t2 =

21

r2 =

c2 =

0.9959 + 0.0000i -0.4895 - 0.0718i -0.4895 + 0.0718i


-0.0036 + 0.0000i 0.6778 + 0.0000i 0.6778 + 0.0000i
-0.0901 + 0.0000i -0.0086 + 0.5439i -0.0086 - 0.5439i

d2 =

6.7240 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i


0.0000 + 0.0000i 7.1380 + 8.7211i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.0000 + 0.0000i 7.1380 - 8.7211i

>>

Department of Mechatronics Engineering


Lab Manual ME 3602 Control System SZABIST

Appendix:
Complete at your end, all command has to be list down. (must be Hand Written)

Command Description
randi Create Uniformly distributed pseudorandom integers
inv
det
plot
eig
eye
zeros
ones
hold on
grid
sin
cos
xlabel
ylabel
title
A‘

Department of Mechatronics Engineering

You might also like