Matrix calculation indexing conditional

조회 수: 1 (최근 30일)
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2019년 8월 13일
댓글: Andrei Bobrov 2019년 8월 15일
I have a matrxi of 500 rows and 6 columns. I need to sum all the rows of 2nd column of the matrix if their 3rd column and 4th coumns equal to specific numbers.
How can I do that?
Lets explain more: One column is the time. An other column is radius. We can have multiple rows of the same time. Or multiple rows that have the same radius. An other coulmn is number of cells. I want to say for all times=2 and all radius=3 sum the number of cells.
  댓글 수: 2
darova
darova 2019년 8월 13일
Do you have any attempts?
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2019년 8월 13일
No

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

채택된 답변

Andrei Bobrov
Andrei Bobrov 2019년 8월 13일
편집: Andrei Bobrov 2019년 8월 13일
Let A - your array (500 x 6):
T = array2table(A);
T_out = varfun(@sum,T,'InputVariables',2,'GroupingVariables',3:4);
  댓글 수: 9
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2019년 8월 14일
Can you explain more? Because time and radius donot have the same size.
Andrei Bobrov
Andrei Bobrov 2019년 8월 15일
GroupCount this is numbers of the same rows in the sub-matrix of two columns - [time, radius]

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by