Calculate a mean if one statement is true for a previous row
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a matrix that has several rows and columns of data. I am trying to get a mean from all the values of row 6 but data is only included if row 5 = 0 in the previous column of data.
OverallM = mean(cellm(6,~(cellm(5,:))));
For example the code above will give me my mean for row 6 if row 5 has a 0 for the same column as row 6. How would I modify this so that it would give me my mean if row 5 has a 0 for the previous column.
Here is an example of my data format.
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
4 0 0 0 0 4 4 0 0 0
11 11 11 11 11 22 22 11 11 11
0 1 0 1 1 1 1 1 0 1
357 567 267 800 927 417 603 564 765 488
0 1 1 1 1 0 0 1 1 1
1 1 1 1 1 2 2 1 1 1
1 0 0 0 0 0 0 0 0 0
In the case above I would want the mean of 567, 800, and 488 because row 5 in the previous column was a 0.
Any suggestions would be appreciated.
Thank you
댓글 수: 0
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!