MATLAB: How to find the top 10% value of the matrix

%homework

HI,
I have a 10×10 matrix and the value is random
How do I find the the top 10% value of the matrix?
ex: if the value is 1~100,I want to get the answer is 90~100
Thanks~

Best Answer

x = the_matrix;
[~,idx] = sort(x(:));
y = x(idx(1:10));