MATLAB: How to multiply two matrices with nested for loops

arraymatrixmultiple

How can I do that with two matrices with any dimensions that can multiply ? Thank you

Best Answer

A=rand(n,p);
B=rand(p,m);
C=zeros(n,m);
for i=1:n
for j=1:m
C(i,j)=0.0;
for k=1:p
C(i,j) = C(i,j)+A(i,k)*B(k,j);
end
end
end
Best wishes
Torsten.