Reputation: 235
There are 12 numbers present in an 4x3 matrix and I need to find out the top 5 highest numbers among them. For example,
B=[11 13 21;10 8 5;3 2 6;7 18 6]
Thus the top 5 highest numbers should be
ans=[21;18;13;11;10]
How could I go about doing it?
Upvotes: 0
Views: 931
Reputation: 7213
Sort the data:
Bsorted = sort(B(:), 'descend');
And pick the top 5:
Btop5 = Bsorted(1:5);
Upvotes: 2