Clear Filters
Clear Filters

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

4 views (last 30 days)
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.

Accepted Answer

James Tursa
James Tursa on 2 Mar 2018
result = sum(myarray>=10.5,3);
  3 Comments
Image Analyst
Image Analyst on 3 Mar 2018
Edited: Image Analyst on 3 Mar 2018
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 on 3 Mar 2018
@Espen: You almost had the syntax correct:
sum(myarray1>=10.5 & myarray2>=50,3)

Sign in to comment.

More Answers (0)

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!