MATLAB: Syntax to multiply 10 different 2 by 2 matrices sequentially in matlab

multiple multiplication of matrices

Please I need help with syntax to multiply ten 2 by 2 matrices i.e T = A1*A2*A3*A4*A5*A6*A7*A8*A9*A10 in matlab

Best Answer

A = cat(3,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10);
s = size(A,3);
out = A(:,:,1);
for jj = 2:s
out = out*A(:,:,jj);
end
or
A = {A1,A2,A3,A4,A5,A6,A7,A8,A9,A10};
out = A{1};
for jj = 2:numel(A)
out = out*A{jj};
end
or for "element by element" multiplication
A = cat(3,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10);
out = prod(A,3);