topkrows
Top k sorted rows of a matrix.
📝Syntax
B = topkrows(A, k)
B = topkrows(A, k, col)
B = topkrows(A, k, col, direction)
[B, I] = topkrows(...)
📥Input Arguments
Parameter Description
A a matrix.
k the number of rows to return.
col the columns used for sorting (default all).
direction 'descend' (default) or 'ascend'.
📤Output Arguments
Parameter Description
B the first k rows of the sorted matrix.
I the indices such that B = A(I, :).
📄Description

B = topkrows(A, k) returns the first k rows of A sorted in descending order.

💡Examples
[B, I] = topkrows([3 1; 1 2; 2 9], 2)
🔗See Also
sortrowsissortedrows
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub