I have a huge vector. I have to count values falling within certain ranges. the ranges are like 0-10, 10-20 etc. I have to count the number of values which fall in certain rang
to count the values in a specific range you can use ismember,
ismember
if m1 is vector use,
m1
k = sum(ismember(m1,0:10));
If m1 is matrix use k = sum(sum(ismember(m1,0:10)));
k = sum(sum(ismember(m1,0:10)));
for example,
m1=randi(20,[5 5]) 9 10 6 10 16 8 9 14 20 6 16 13 14 7 11 16 15 4 12 14 4 16 3 5 18 sum(sum(ismember(m1,1:10))) 12