How can i operate on every row of a matrix without using any loop?

3 次查看(过去 30 天)
I have to find the cumulative sum of every row seperately without using any kind of loops in the following matrix;
c = exprnd(1,1000,100);
so i should get a thound rows of cumsum(exprnd(1,1,100)).

采纳的回答

DGM
DGM 2021-4-21
Something like this:
A=randi(9,4)
B=cumsum(A,2)
gives:
A =
8 6 9 9
9 1 9 5
2 3 2 8
9 5 9 2
B =
8 14 23 32
9 10 19 24
2 5 7 15
9 14 23 25

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by