MATLAB: How to multiply elements of a cell array with each other

cell arraysmultiplication

Hi,
I have a 1xN cell array with each cell containing 2×2 matrix. I want to now multiply the individual cell arrays to get a single matrix. I used the following code but it is just multiplies the last two:
prompt = 'enter number of transformations'
N = input(prompt); %to enter number of matrixes user wants to multiply
A = cell(1,N);
%storing matrices in a 1xN cell array
for i = 1:1:N
prompt = 'enter transformation matrix'
A{1,i} = input(prompt);
end
%want to get a single multiplication matrix of all N cells
for i = 1:1:N
T = A{1,i}*A{1,:i+1};
end

Best Answer

You should be aware that matrix multiplication is not commutative (A*B does not equal B*A, in general). A for-loop is the best option
T = A{1} ;
for k = 2:numel(A)
T = T * A{k}
end