How can I find the top 5% values' index in a 3D matrix
Show older comments
I want to find the top 5% values' index in a 3D matrix
Answers (2)
X = rand(10, 10, 3); % sample data
[~, idx] = sort(X(:));
Linear indices:
idxtop5perc = idx(end-5*numel(X)/100+1:end)
Subscripts:
[i, j, k] = ind2sub(size(X), idxtop5perc);
Guillaume
on 17 Nov 2015
demodata = rand(100, 50, 20); %a 3d matrix;
[values, idx] = sort(demodata, 'descend');
%depending on what is meant by top 5%:
%5% of the population
idxpop = idx(1:ceil(end/20))
%5% of the maximum value
idxval = idx(values >= values(1)*.95)
sort your data and filter it any way you want.
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!