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 endBest wishesTorsten. Related SolutionsMATLAB: Offset matrix multiplication with loop % test dataA = randi(10,3,4) B = cumsum(ones(size(A))) % engineC = A(2:end,:) .* B(1:end-1,:) % C(i,j) = A(i+1,j) * B(i,j) MATLAB: How to multiply two matrices a = [1,2,3;9,8,7] ;b = [5,8;8,7;9,4] ; % ab = [48,34;172,156] ;[n,p] = size(a) ;[p,m] = size(b) ;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 Related QuestionExtracting a 2 dimensional array from a 3 dimensional matrix.Skipping 1st two calculations of a loopIndex exceeds matrix dimensions. ?? I want to create matrix 3×3 kernelSomeone correct me please! How can i plot with this codes to get the following graphHow to multiply two matrices
Best Answer