MATLAB Answers

0

3D data cumsum does not work

Asked by Fikret Dogru on 9 Feb 2019
Latest activity Commented on by Fikret Dogru on 9 Feb 2019
Hello all,
I have a 3D data like 2532X3542X26. I combined 26 number of 2D data 2532X3542 because of some reason. So now, I want to sum of the all matrices like following:
qq(:,:,1)=R(:,:,1);
qq(:,:,2)=R(:,:,1)+R(:,:,2);
qq(:,:,3)=R(:,:,1)+R(:,:,2)+R(:,:,3);
qq(:,:,4)=R(:,:,1)+R(:,:,2)+R(:,:,3)+R(:,:,4);
qq(:,:,5)=R(:,:,1)+R(:,:,2)+R(:,:,3)+R(:,:,4)+R(:,:,5);
qq(:,:,6)=R(:,:,1)+R(:,:,2)+R(:,:,3)+R(:,:,4)+R(:,:,5)+R(:,:,6);
qq(:,:,7)=R(:,:,1)+R(:,:,2)+R(:,:,3)+R(:,:,4)+R(:,:,5)+R(:,:,6)+R(:,:,7);
qq(:,:,8)=R(:,:,1)+R(:,:,2)+R(:,:,3)+R(:,:,4)+R(:,:,5)+R(:,:,6)+R(:,:,7)+R(:,:,8);
qq(:,:,9)=R(:,:,1)+R(:,:,2)+R(:,:,3)+R(:,:,4)+R(:,:,5)+R(:,:,6)+R(:,:,7)+R(:,:,8)+R(:,:,9);
.
.
until qq(:,:,26)=R(:,:,1)+R(:,:,2)+R(:,:,3)+R(:,:,4)+R(:,:,5)+R(:,:,6)+R(:,:,7)+R(:,:,8)+R(:,:,9)+......+R(:,:,26);
Please help me another way to do it. I do not use like a this way. I need a for loop but I could not achieve it correctly. Thanks all
Fikret

  0 Comments

Sign in to comment.

1 Answer

Answer by John D'Errico
on 9 Feb 2019
 Accepted Answer

Oh. So it does not work if you do this?
qq = cumsum(rr,3);
I guess you should report that as a bug, because it works for me. I wonder why it fails for you? :)

  1 Comment

Oh sorry, I see. Thank you so much.

Sign in to comment.