MATLAB EXPERIMENT 3
MATLAB EXPERIMENT 3
3.1 Objectives
Generate a matrix and perform basic operation on matrices using MATLAB software.
MATLAB treats all variables as matrices. Vectors are special forms of matrices and contain
only one row or one column. Whereas scalars are special forms of matrices and contain only
one row and one column. A matrix with one row is called row vector and a matrix with single
The first one consists of convenient matrix building functions, some of which are given
below:
3.4 Programs:
>> sub_m=m(2:3,2:3)
sub_m =
69
69
❖ matrix multiplication
>> x1=a*b
x1 =
308
10 32 50
-1 -2 -5
❖ matrix addition
>> x3=a+b
x3 =
262
-1 1 11
036
❖ matrix subtraction
>> x4=a-b
x4 =
2 2 -4
-3 1 7
-2 -5 -6
❖ matrix division
>> x5=a/b
x5 =
-9.0000 -3.5000 5.5000
12.0000 3.7500 -5.7500
3.0000 0.7500 -1.7500
❖ inverse of matrix a
>> x7=inv(a)
x7 =
-0.4286 -0.0476 -1.7619
0.4286 0.0476 0.7619
-0.1429 0.0952 -0.4762
❖ transpose of matrix a
>> x8=a'
x8 =
2 -2 -1
4 1 -1
-1 9 0