Measurement and Instrumentation Laboratory
Measurement and Instrumentation Laboratory
Introduction to MATLAB
The purpose of this manual is to introduce you with some basic operations of
Matlab that we encounter in our everyday life.
The Matlab prompt “>>” indicates where the commands are entered by the user.
The command is processed by the Matlab and the corresponding output is
displayed on the next line.
>> a=3
>> b=4
>> x=a+b
‘-‘ subtraction
‘*’ multiplication
‘/’ division
‘^’ power
‘( )’ brackets
Please execute the following commands, and write the output. Also try to solve
these on your own using simple algebraic techniques and check your answer with
the Matlab output.
- 2+3/4*5
- ((5*3)/4)+3*7-2
- 7/3+5*3-2^3
Matlab actually deals with MATRICES or VECTORS. Let us start with a basic
row vector having values in a single row as 1 2 3 4 5 and we want to name it a
variable ‘x’
>> x=[1 2 3 4 5]
>>x=[1,2,3,4,5]
Now use ‘;’ in place of ‘,’ in the above command. What happened?
__________________________________________________________________
__________________________________________________________________
Now make your own matrix having 3 rows with elements 1 2 3 in 1st row, 2 4 6 in
2nd row and 3 5 7 in the 3rd row. Your matrix is ‘x’
Try to find the size and transpose of the matrix using suitable commands. Use help
command to find the solution e-g
>>y=[0:6]
>>y(1,1)
>>y(1:1)
>>y[1:2:6]
>>y(2,2)
Bonus Assignment: Make a 3 by 3 matrix and try to find out its product with
another 3 by 3 matrix, then find the determinant and inverse of the product
matrix.