Exercise 14 Solution
function C = exercise_14(A,B)
%{
Multiplies two matrices if the sizes match, otherwise prints error.
Example of usage:
A = randi(10,[3 5])
B = randi(10,[5 7])
C = exercise_14(A,B)
%}
[m1,n1] = size(A);
[m2,n2] = size(B);
if n1~=m2, error('Size mismatch'); end;
C = zeros(m1,n2);
for i = 1:m1,
for j = 1:n2,
ss = 0;
for k = 1:n1,
ss = ss + A(i,k).*B(k,j);
end
C(i,j) = ss;
end
end