Filter löschen
Filter löschen

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

3 Ansichten (letzte 30 Tage)
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)).

Akzeptierte Antwort

DGM
DGM am 21 Apr. 2021
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
  2 Kommentare
Sarp Özdemir
Sarp Özdemir am 21 Apr. 2021
thank you so much.
what is the function of that 2, i didnt get it?
DGM
DGM am 21 Apr. 2021
That specifies the dimension to operate along. i.e. dim2, rows

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by