% Written by Gun Srijuntongsiri function C=mul(A,B) % MUL multiplies matrix A and B together without using % Matlab's built-in array multiplication (A.*B) % First check for correct dimension if (length(size(A))~= length(size(B))) | any(size(A)~=size(B)) error('The two arrays must have the same dimension.'); end % Then compute the summation entry by entry. for i=1:size(A,1) for j=1:size(A,2) C(i,j) = A(i,j)*B(i,j); end end