Cumprod for cell arrays?
Show older comments
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
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
Firat Eren
on 8 Oct 2018
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
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!