필터 지우기
필터 지우기

Count number of values greater than a certain value in 3d matrix

조회 수: 4 (최근 30일)
LarsFM
LarsFM 2018년 3월 2일
댓글: James Tursa 2018년 3월 3일
I have a 3d matrix sized 40*60*157800. I want to calculate number of values greater than 10.5 of each of the 40x60 values. This will give me a 2d Matrix of 40*60*1. I have tried this code:
sum((myarray,3)>=10.5);
But in only gives me an error. I really need help how to write this code.

채택된 답변

James Tursa
James Tursa 2018년 3월 2일
result = sum(myarray>=10.5,3);
  댓글 수: 3
Image Analyst
Image Analyst 2018년 3월 3일
편집: Image Analyst 2018년 3월 3일
You have to sum the sums:
bothSummed = sum(myarray1>=10.5,3) + sum(myarray2>=50,3);
Of if you want both simultaneously, do
bothSet = myarray1>=10.5 & myarray2>=50; % MUST be the same size arrays.
bothSummed = nnz(bothSet);
James Tursa
James Tursa 2018년 3월 3일
@Espen: You almost had the syntax correct:
sum(myarray1>=10.5 & myarray2>=50,3)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by