Cumprod for cell arrays?

Hi, I have a cell array (R) consisting of 3x3 matrices. For example, R{1,1}=[1 2 3; 4 5 6; 7 8 9].. R{2,1}=[1 3 5; 7 8 9; 10 11 12] . . . . R{20,1}=[ 2 4 6; 2 3 4; 5 6 7]
What I would like to do is cumulatively multiply these 3x3 matrices, like cumprod does in a vector. Is this possible? Thank you,

Answers (2)

KSSV
KSSV on 8 Oct 2018
R{1,1} = rand(3) ;
R{2,1} = rand(3) ;
R{3,1} = rand(3) ;
S = eye(size(R{1})) ;
iwant = R ;
for i = 1:numel(R)
S = S*R{i} ;
iwant{i} = S ;
end

1 Comment

Thank you for your answer. I forgot to mention in the post that I wanted to do the calculation without for loops. Is this operation possible without for loops?

Sign in to comment.

Stephen23
Stephen23 on 8 Oct 2018

0 votes

"Is this operation possible without for loops?"
Not really. A loop is the simplest, clearest solution.

Categories

Find more on MATLAB in Help Center and File Exchange

Asked:

on 8 Oct 2018

Answered:

on 8 Oct 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!