How can I find the top 5% values' index in a 3D matrix
Afficher commentaires plus anciens
I want to find the top 5% values' index in a 3D matrix
Réponses (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
le 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.
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!