MATLAB: How to select the top 5 five values in a matrix

array

If A=rand(5,15) whch generates 5 rows with 15 columns
Could anyone help me how to select the highest 5 values in A.

Best Answer

maxk(A(:),5) % gives the max 5 values of entire matrix
%or
max(A,[],2) % gives max of each row (finally resulting with 5 values)