You are on page 1of 3

Techno India NJR Institute of

Technology
Bhamashah (RIICO) Industrial Area, Kaladwas, Udaipur

Department of Civil/Mechanical Engineering


MATLAB Sheets

Instructors: Dr. Pankaj Porwal


Mr.Kapil
Dungarwal
MATLAB
MAT
MATRIX

LAB
LABORATORY

It was designed to do matrix calculator efficiently. We can think of this as powerful scientific
calculator.
1. Basic Commands
Command Window
Command prompt
>>
We can type command after >>
Pressing enter key after typing command executes the command. For example
>> 2 + 2
ans= 4
This method of doing computation is called interactive method.
Commands
+
Addition
Subtraction
*
Multiplication
/
Division
^
Raise to the power
Trigonometric and Other fuctions
sin
cos
tan
asin = sin-1
acos = cos-1
atan = tan-1
sqrt
pi
exp
in MATLAB we do not have to define/declare variables in advance before using them.

Page 1 of 3

2. Matrix Manipulation
Entering Matrix
All the elements are written within square bracket.
Elements in a row are separately by space or comma.
Rows are separated by semicolon.
Values are entered between square bracket.
Am*n

A=
Size (A)

2 3 4
1 5 3

2 3

=
=

2 3 4
1 5 3

that is (2x3)

A (1, 3)
A (2, 4)
A =

a13
a21

3 9 4
1 6 8

[ ]
2 1 2
7 5 3
9 6 4

Matrix addition A + B
Matrix Subtraction A - B
Scalar Multiplication 2*A
Matrix multiplication
A*C
A*B
Determinant of a matrix
det (C) =
det( A) =
Transpose of a matrix
Inverse of a matrix

(matrix multiplication)
(will not work, why?)
-3
(will not work, why?)
A , B , C
inv (C)
Inv(B) will not work

System of linear
Solve 2x + y + 3z = 1
2x + 6y + 8z = 3
6x + 8y + 18z = 5
Page 2 of 3

Ax = b

A =

[]

2 1 3
2 6 8
6 8 18

1
3
5

x = A-1 * b =

[]
0.3
0.4
0

Example:1. Solve
3x + y -6z = -10
2x + y -5z = -8
6x 3y +3z = 0
Rank of a matrix:- rank(A)
Eigen value and Eigen vectors
eig (A) gives eigen values.
[V,D] = eig (A) gives both eigen values and eigenvectors
V = matrix whose column are eigen vectors.
D = matrix whose diagonal element are eigen values.
Find rank, eigen values and eigen vectors for following matrices

(1)

(2)

[ ]

2 4 7
1 3 5
3 7 12

1 6 2
5 4 3
1 8 7

Page 3 of 3

You might also like