필터 지우기
필터 지우기

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

조회 수: 3 (최근 30일)
Sarp Özdemir
Sarp Özdemir 2021년 4월 21일
댓글: DGM 2021년 4월 21일
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
  댓글 수: 2
Sarp Özdemir
Sarp Özdemir 2021년 4월 21일
thank you so much.
what is the function of that 2, i didnt get it?
DGM
DGM 2021년 4월 21일
That specifies the dimension to operate along. i.e. dim2, rows

댓글을 달려면 로그인하십시오.

추가 답변 (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