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
You can use logical indexing. Observe:
>> x = randi(40, 1, 10) - 20 x = -2 17 -12 -9 -14 -14 15 4 2 -14 >> x2 = x(0 < x & x < 10) x2 = 4 2 >> length(x2) ans = 2
and the same done in one step:
>> length(x(0 < x & x < 10)) ans = 2