Assuming your average range is [-10 10], the indices will be:
> find(-10< M & M< 10) ans = 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Note that you can also get values by logical indexing, for example:
> M(-10< M & M< 10) ans = Columns 1 through 15: -7.37500 -5.50000 -1.66667 -1.33333 and so on ...
And to get the middle range, simply:
> q= quantile(M(:), [.25 .75]) q = -1.3214 17.0917 > find(q(1)< M & M< q(2)) ans = 8 9 10 11 12 13 14 15 16 17 18 19 20
Note also that M(:) used here to ensure that quantile treats M as a vector. You can accept the agreement that all vectors in your programs are column vectors, then most functions automatically process them correctly.
Update:
Now for a very short description of the quantiles it follows that they are points taken from the cumulative distribution function ( cdf ) of a random variable. (Now your M is considered a kind of cdf , since it is non-decreasing and can be normalized to the amount of up to 1). Now simply “quantile .5 of your data” means that 50% of the values are lower than that quantile. "More detailed information on quantiles can be found, for example, here .
source share