The whole idea is to conver matrix-matrix multiplication to matrix-vector multiplication.
Not commutative:
Identity matrix:
% Initialize random matrices A and B A = [1,2;4,5] B = [1,1;0,2] % Initialize a 2 by 2 identity matrix I = eye(2) % The above notation is the same as I = [1,0;0,1] % What happens when we multiply I*A ? IA = I*A % How about A*I ? AI = A*I % Compute A*B AB = A*B % Is it equal to B*A? BA = B*A % Note that IA = AI but AB != BA """ A = 1 2 4 5 B = 1 1 0 2 I = Diagonal Matrix 1 0 0 1 IA = 1 2 4 5 AI = 1 2 4 5 AB = 1 5 4 14 BA = 5 7 8 10 """