The 'prctile' function does not provide an automatic way to extract the values of your data that constitute a certain percentile. However, you can use 'prctile' along with another couple lines of code to obtain these values. Below are a couple examples:
Method 1:
>> m = rand(1, 20);
>> percentiles = prctile(m, [10 20 30]);
>> vals10 = m(m <= percentiles(1));
>> vals20 = m(m <= percentiles(2));
>> vals30 = m(m <= percentiles(3));
Method 2:
>> m = rand(1, 20);
>> mSorted = sort(m);
>> vals10 = mSorted(1:floor(end * 0.1));
>> vals20 = mSorted(1:floor(end * 0.2));
>> vals30 = mSorted(1:floor(end * 0.3));
Note: Method 2 does not calculate the percentiles, just the values that constitute each percentile. It also does not keep the data in its original order.
Best Answer