Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matrix multiplication of matrix sequences

I searched for a way to do a sequential matrix multiplication similarly to the sum(A,dim) or prod(A,dim) operations do for the sum or the element-wise multiplication.

for example:

A = arrayfun(@(x) rand(5), 1:n, 'UniformOutput', false);
P = A{1} * A{2} * ... * A{n};  % <-- search for an elegant way to do this

I would use it to multiply a large number of Transfer matrices.

like image 976
Uri Zondiner Avatar asked Jun 14 '16 17:06

Uri Zondiner


1 Answers

Use a for loop for this. It is what an 'elegant' method would do eventually.

P = A{1};
for i=2:length(A), P = P * A{i}, end
like image 91
Tom Avatar answered Sep 30 '22 20:09

Tom