MATLAB: How do i get the top 10 percent of the matrix value

extractmatrixpercentage

so basically I have a matrix of 20×20. I need to extract out the top 10 percentage of the value and put it into a vector form. how should I do it?

Best Answer

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