function m = matrix_add(a, b) % matrix_add(a,b) % Adds the values of two matrices together. % Does the same thing as .* but using loops % David Kauchak % 11/29/11 if size(a) ~= size(b) disp('Matrices must be same size') else m = zeros(size(a)); [nrows, ncols] = size(a); for i = 1:nrows for j = 1:ncols m(i,j) = a(i,j) + b(i,j); end end end