Lab Manual Template Solved
Lab Manual Template Solved
Submitted by
Instructor
CERTIFICATE
_________________ __________________
TABLE OF CONTENTS
TABLE OF CONTENTS 1
CLOs PLOs Mapping and List of Experiments 2
Lab Title 1
LAB MANUAL Mechanical Instrumentation & Control
An Introduction to MATLAB
Lab Outcomes:
To become familiar with the basics of Matlab.
Theory:
What is MATLAB
The name MATLAB is short for MATrix LABoratory. It is a commercial software
package whose main function is to perform calculations on matrices, row vectors and
column vectors. It is widely used in both industry and academic institutions. It possesses
many of the features of a high level, numerically oriented programming language, but in
addition has a large collection of built-in functions for performing matrix and vector
operations in a way that is very simple for the user. For example, to find the determinant
of a matrix A one need only enter:
det(A)
MATLAB commands can be entered one line at a time, or the user can write programs of
MATLAB code and define his or her own functions. In this session, we shall only use the
one-line-at-a-time “interpretive” mode for simplicity, but the regular user will find that
the power of the package is considerably extended by writing his or her own programs
and functions.
Entering and quitting MATLAB
To enter MATLAB, simply double click on the MATLAB icon. To leave MATLAB and
return to the PC’s operating system
Simply type: quit
Creating and manipulating matrices and vectors
1
LAB MANUAL Mechanical Instrumentation & Control
MATLAB works on matrices and vectors that may be real or complex. Variables do not
have to be “declared”. Results can be displayed in a variety of different formats.
Let us enter a row vector into the MATLAB workspace. Type in:
v = [2 4 7 5]
This creates a variable v whose current value is a row vector with four elements as
shown. After pressing “return” the value of v will have been echoed back to you. To
suppress the echo, one uses a semi-colon following the command line. Thus
w = [1 3 8 9];
Creates another row vector w, but does not echo. To check that w has appeared in the
MATLAB workspace, type,
who
Which will display all the variables in the MATLAB workspace, and to check the value
of w simply type w
Operations on row vectors can be best illustrated by some simple exercises.
Equipment:
1) PC
2) MATLAB Version 7 or above
Procedure:
Exercise#1: Investigate the effect of the following commands:
(a) v(2) (b) sum = v + w (c) diff = v – w (d) vw = [v w]
(e) vw(2:6) (f) v’
One way to generate a column vector is to take the transpose of a row vector, as you will
have found in exercise 1(f). Column vectors can be typed in directly in one of two ways.
For example, to enter the command vector
[]
1
z= 1
0
0
you can type
z = [1; 1; 0; 0]; or
z = [1
1
0
2
LAB MANUAL Mechanical Instrumentation & Control
0];
(i) z’ (b) z*v (c) [v; w] (d) v*z (e) [z; v’] (f) z + v’
One way of creating matrices is by multiplying row and column vectors as seen in the
above exercises. There are various ways of entering matrices. For example, to enter the
matrix
M=
[ ]
1 2
3 4
the most obvious ways are to type
M = [1 2; 3 4]; or
M = [1 2
3 4];
but there are more perverse ways such as
M = [[1 3]’[2 4]’];
(a) N = inv(M) (b) M*N (c) I = eye(2) (d) M + I (e) M*z(1:2) (f) v(3:4)*M
(g) M(1,1) (h) M(1:2,1:2) (i) M(:,1) (j) M(2,:)
Observations:
Exercise # 1:
>> v = [2 4 7 5]
v=
2 4 7 5
>> w = [1 3 8 9];
>> v(2)
ans =
>> sum = v + w
sum =
3
LAB MANUAL Mechanical Instrumentation & Control
3 7 15 14
>> diff = v - w
diff =
1 1 -1 -4
>> vw = [v w]
vw =
2 4 7 5 1 3 8 9
>> vw(2:6)
ans =
4 7 5 1 3
>> v'
ans =
2
4
7
5
Exercise # 2:
>> z = [1; 1; 0; 0];
>> z'
ans =
1 1 0 0
>> z*v
ans =
4
LAB MANUAL Mechanical Instrumentation & Control
2 4 7 5
2 4 7 5
0 0 0 0
0 0 0 0
>> [v; w]
ans =
2 4 7 5
1 3 8 9
>> v*z
ans =
ans =
1
1
0
0
2
4
7
5
>> z + v'
ans =
3
5
7
5
Exercise # 3:
>> M = [1 2; 3 4];
5
LAB MANUAL Mechanical Instrumentation & Control
>> N = inv(M)
N=
-2.0000 1.0000
1.5000 -0.5000
>> M*N
ans =
1.0000 0
0.0000 1.0000
>> I = eye(2)
I=
1 0
0 1
>> M + I
ans =
2 2
3 5
>> M*z(1:2)
ans =
3
7
>> v(3:4)*M
ans =
22 34
>> M(1,1)
6
LAB MANUAL Mechanical Instrumentation & Control
ans =
>> M(1:2,1:2)
ans =
1 2
3 4
>> M(:,1)
ans =
1
3
>> M(2,:)
ans =
3 4
7
LAB MANUAL Mechanical Instrumentation & Control
Conclusion:
In this lab, we successfully achieved the objective of becoming familiar with MATLAB.
We explored its interface, basic functionalities, and key commands.
References:
https://www.mathworks.com/help/matlab/getting-started-with-matlab.html
8
LAB MANUAL Mechanical Instrumentation & Control
Rubrics
Student is Student can Student has Student has Student
unable to understand followed constructed perfectly
follow the the provided instructions the implemented a
provided laboratory to construct functional/ working
instructions instructions the working model/ logic/
properly. and familiar fundamental schematic/ circuit/ block
with the lab schematic/ model/ block diagram/ code
The student
environment block diagram/ and
can name the
(Trainer/ diagram/ code, and successfully
Demonstration Absent hardware or
software/ code/ model have executed the
simulation
IDE), but on the successfully lab objective
platform, but
cannot protoboard/ executed the in Realtime or
unable to
implement trainer/ program/ run in a
implement
on the simulation circuit on simulation
anything
platform software. software environment
practically or
practically or platform and produced
on the
on the the desired
software
software results
Marks 0.0 0.01 - 0.20 0.21 - 0.40 0.41 - 0.60 0.61 - 0.80 0.81 - 1.0
Correctly
drawn
Plagiarized Requirements Observations Appropriate conclusion
content are listed and are recorded computations with
Laboratory Report not
presented or experimental along with or numerical
Reports submitted exact results
incomplete procedure is detailed analysis is
submission presented procedure performed and complete
report in all
respects
Marks 0.0 0.01 - 0.20 0.21 - 0.40 0.41 - 0.60 0.61 - 0.80 0.81 - 1.0
9
LAB MANUAL Mechanical Instrumentation & Control
10
LAB MANUAL Mechanical Instrumentation & Control
Lab Outcomes:
To become familiar with the Basic Scalar Operations of Matlab.
Theory:
When you add, subtract, multiply or divide a matrix by a number, this is called the scalar
operation.
Scalar operations produce a new matrix with same number of rows and columns with each
element of the original matrix added to, subtracted from, multiplied by or divided by the number.
Equipment:
1) PC
2) MATLAB Version 7 or above
Procedure:
disp(‘YOUR NAME, YOUR CMS ID’) % this command displays what we type as a string.
x=x+1 % Incrementing x by 1.
z=2*x % Declaring z.
z % Sowing value of z.
11
LAB MANUAL Mechanical Instrumentation & Control
who %It shows all the variable that are stored in memory.
Observations:
x=
>> x
x=
>> y = 2*x
y=
>> y
y=
12
LAB MANUAL Mechanical Instrumentation & Control
>> x = x+1
x=
>> z = 2*x
z=
>> z
z=
diff =
>> who
diff x y z
>> whos
Name Size Bytes Class Attributes
13
LAB MANUAL Mechanical Instrumentation & Control
w x y
Conclusion:
In this lab, we successfully performed basic scaler operations.
References:
https://www.mathworks.com/help/matlab/getting-started-with-matlab.html
14
LAB MANUAL Mechanical Instrumentation & Control
Rubrics
Student is Student can Student has Student has Student
unable to understand followed constructed perfectly
follow the the provided instructions the implemented a
provided laboratory to construct functional/ working
instructions instructions the working model/ logic/
properly. and familiar fundamental schematic/ circuit/ block
with the lab schematic/ model/ block diagram/ code
The student
environment block diagram/ and
can name the
(Trainer/ diagram/ code, and successfully
Demonstration Absent hardware or
software/ code/ model have executed the
simulation
IDE), but on the successfully lab objective
platform, but
cannot protoboard/ executed the in Realtime or
unable to
implement trainer/ program/ run in a
implement
on the simulation circuit on simulation
anything
platform software. software environment
practically or
practically or platform and produced
on the
on the the desired
software
software results
Marks 0.0 0.01 - 0.20 0.21 - 0.40 0.41 - 0.60 0.61 - 0.80 0.81 - 1.0
Correctly
drawn
Plagiarized Requirements Observations Appropriate conclusion
content are listed and are recorded computations with
Laboratory Report not
presented or experimental along with or numerical
Reports submitted exact results
incomplete procedure is detailed analysis is
submission presented procedure performed and complete
report in all
respects
Marks 0.0 0.01 - 0.20 0.21 - 0.40 0.41 - 0.60 0.61 - 0.80 0.81 - 1.0
15
LAB MANUAL Mechanical Instrumentation & Control
Lab Outcomes:
To become familiar with the Signal Generation and Plotting of sinosoidal function of
Matlab.
Theory:
Sinusoidal function is a function that is based on the sine function, which is a periodic function
that smoothly oscillates between high and low values. Sinusoidal functions can also be based on
the cosine function since it is just a horizontal shift of the sine function. The most basic
sinusoidal function is the function sin(x)
Equipment:
1) PC
2) MATLAB Version 7 or above
Procedure:
A=4; %Set Amplitude
w=20*pi; %Set Phase
16
LAB MANUAL Mechanical Instrumentation & Control
Observations:
17
LAB MANUAL Mechanical Instrumentation & Control
Conclusion:
In this lab, we explored the use of the MATLAB plot function for graphical
representation. Additionally, we generated and analyzed a basic sinusoidal waveform.
References:
https://www.mathworks.com/help/matlab/ref/plot.html
18
LAB MANUAL Mechanical Instrumentation & Control
Rubrics
Student is Student can Student has Student has Student
unable to understand followed constructed perfectly
follow the the provided instructions the implemented a
provided laboratory to construct functional/ working
instructions instructions the working model/ logic/
properly. and familiar fundamental schematic/ circuit/ block
with the lab schematic/ model/ block diagram/ code
The student
environment block diagram/ and
can name the
(Trainer/ diagram/ code, and successfully
Demonstration Absent hardware or
software/ code/ model have executed the
simulation
IDE), but on the successfully lab objective
platform, but
cannot protoboard/ executed the in Realtime or
unable to
implement trainer/ program/ run in a
implement
on the simulation circuit on simulation
anything
platform software. software environment
practically or
practically or platform and produced
on the
on the the desired
software
software results
Marks 0.0 0.01 - 0.20 0.21 - 0.40 0.41 - 0.60 0.61 - 0.80 0.81 - 1.0
Correctly
drawn
Plagiarized Requirements Observations Appropriate conclusion
content are listed and are recorded computations with
Laboratory Report not
presented or experimental along with or numerical
Reports submitted exact results
incomplete procedure is detailed analysis is
submission presented procedure performed and complete
report in all
respects
Marks 0.0 0.01 - 0.20 0.21 - 0.40 0.41 - 0.60 0.61 - 0.80 0.81 - 1.0
19
LAB MANUAL Mechanical Instrumentation & Control
20