How can I find the top 5% values' index in a 3D matrix
Mostrar comentarios más antiguos
I want to find the top 5% values' index in a 3D matrix
Respuestas (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
el 17 de Nov. de 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.
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!