Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
4x3 矩阵中有 12 个数字,我需要找出其中前 5 个最高的数字。例如,
B=[11 13 21;10 8 5;3 2 6;7 18 6]
因此,前 5 个最高的数字应该是
ans=[21;18;13;11;10]
我该怎么做呢?
Sort the data:
Bsorted = sort(B(:), 'descend');
And pick the top 5:
Btop5 = Bsorted(1:5);