Finding top and bottom 10% of data
86 次查看(过去 30 天)
显示 更早的评论
Hello, I have a 1240x1 matrix of data and I wish to find the positions which contain the top 10% and the bottom 10% of the data (i.e. I shoud have 124 identified data points for the top 10% and 124 identified data points for the bottom 10%). Then, I would like to be able to create a new matrix containing just the top 10% data points and another matrix containing just the bottom 10% data points. Any assistance on how I can code this up would be greatly appreciated!
1 个评论
Image Analyst
2021-10-11
编辑:Image Analyst
2021-10-11
Is your data sorted, or can the top and bottom 10% of the data be scattered anywhere around in your vector? Is the 10% defined by the number of points,
percent10 = round(0.1 * numel(vector)) % 12 elements
, or is it defined by the values
percent10 = min(vec) + 0.1 * (max(vec) - min(vec));
percent90 = min(vec) + 0.9 * (max(vec) - min(vec));
which could be any number of elements? How many elements do you want to find? 12 or some variable number depending on the values?
Or do you want the 10% and 90% points defined by the CDF of the values?
回答(2 个)
David Hill
2021-10-11
编辑:David Hill
2021-10-11
n=round(.1*numuel(yourMatrix));
[~,idx]=sort(yourMatrix);
bottom=yourMatrix(idx(1:n));
top=yourMatrix(idx(end-*n+1:end));
0 个评论
Star Strider
2021-10-12
x = randn(1,20) % Create Vector
v = prctile(x, [10,90]) % Determine 10th, 90th Percentiles
x10 = find(x<=v(1)) % Indices Of ELements At Or Below 10th Percentile
x90 = find(x>=v(2)) % Indices Of ELements At Or Above 90th Percentile
.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!