count elements falling within certain thresholds in array in matlab? -
i have huge vector. have count values falling within ranges. ranges 0-10, 10-20 etc. have count number of values fall in range.
i did :
for i=1:numel(m1) if (0<m1(i)<=10)==1 k=k+1; end end
also:
if not(isnan(m1))==1 x=(0<m1<=10); end
but both times gives array contains 1s. wrong doing?
you can (also works non integers)
k = sum(m1>0 & m1<=10)
Comments
Post a Comment