Matrices in
MATLAB
Made By : Nikhil And
Gaurav
How to create Matrix .
 By entering elements in each row as comma or
space delimited numbers and using semicolons to
mark the end of each row.
1 2 3 4 5
2
3
4
3
4
5
4
5
6
5
6
6
7
87
a = [ 1 2 3 4 5 ; 2 3 4 5 6 ; 3 4 5 6 7; 4 5 6 7 8]
Referencing the Elements of a Matrix
1 2 3 4 5
2
3
4
3
4
5
4
5
6
5
6
6
7
87
a(2,5)  ans = 6
a(3,2)  ans = 4
Referencing full column
1 2 3 4 5
2
3
4
3
4
5
4
5
6
5
6
6
7
87
a(: , 5)  5
6
7
8
Referencing full column
1 2 3 4 5
2
3
4
3
4
5
4
5
6
5
6
6
7
87
a(1 ,:)  1 2 3 4 5
Referencing more than one
column
1 2 3 4 5
2
3
4
3
4
5
4
5
6
5
6
6
7
87
a( : , 1:3)  1 2 3
2
3
4
3
4
5
4
5
6
Referencing rows and column
1 2 3 4 5
2
3
4
3
4
5
4
5
6
5
6
6
7
87
a(1:2 , 1:2)  1 2
2 3
Matrix
Operation in
Matlab
Using Zeros function
 b = zeros( 2 , 3)
0 0 0
0 0 0
Identity Matrix
 Create a 4-by-4 identity matrix
I = eye(4) 
1 0 0 0
0
0
0
1
0
0
0
1
0
0
0
1
Transpose of Matrix
1 2 3 4 5
2
3
4
3
4
5
4
5
6
5
6
6
7
87
• b = a.‘
• b= transpose(a)
1 2
2
1 2 3 4
2
3
4
3
4
5
4
5
6
5
6
7
5 6 7 8
Transpose 
Matrix Concatenation
3
1 2
2 5
2 3
4
a=
b=
c = [ a b ]  row wise concatenation
3
1 2
2 5
2 3
4
c = [ a ; b ]  column wise concatenation
3
1 2
2
5
2 3
4
Matrices in matlab

Matrices in matlab