Saturday 29 August 2015

OPERATIONS ON MATRICES USING MATLAB

code for adding two matrices:  ( '+' operator is used for summing two matrices)

a = [ 1 2 3 ; 4 5 6 ; 7 8 9] 
b= [ 1 0 0 ; 0 1 0; 0 0 1] 
c = a+b
Screenshot (14)

code for matrix subtraction: ('-' operator is used for subtraction. It is done using 2x2 matrices)
a = [ 2  2 ; 4  4] 
b = [1   0 ; 0  0] 
c = a-b

Screenshot (15)

multiplying matrices: (' * 'operator is used for multiplication)
a = [ 1  2  ; 3  4 ] 
b = [ 1 0 ; 0  1] 
c = a*b

Screenshot (16)

No comments:

Post a Comment