how do i get the top 10 percent of the matrix value

6 visualizzazioni (ultimi 30 giorni)
so basically I have a matrix of 20x20. I need to extract out the top 10 percentage of the value and put it into a vector form. how should I do it?

Risposta accettata

Star Strider
Star Strider il 20 Ott 2015
This seems to do what you want:
M = randn(20); % Create Data
Ms = sort(M(:),'descend'); % Sort Descending
Result = Ms(1:ceil(length(Ms)*0.1)); % Desired Output
  4 Commenti
jun xian ng
jun xian ng il 20 Ott 2015
oh, I see. I get it now. Thanks alot

Accedi per commentare.

Più risposte (1)

Walter Roberson
Walter Roberson il 20 Ott 2015
V = sort(YourMatrix(:), 'reverse');
Top10 = V(1:ceil(end/10));

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by