14 lines
545 B
Matlab
14 lines
545 B
Matlab
function [v, idx] = maxk (x, k, varargin)
|
|
%MAXK The k largest elements, in descending order (MATLAB R2017b+).
|
|
%
|
|
% An owuitools compatibility shim; see contains.m for the policy.
|
|
% Column-wise for a matrix, like MATLAB and like `sort`. NaNs go last,
|
|
% which is also what MATLAB does. `k` larger than the data returns
|
|
% everything there is rather than erroring, again matching MATLAB.
|
|
|
|
if (nargin < 2)
|
|
error ('maxk: not enough input arguments');
|
|
end
|
|
[v, idx] = owuitools_topk (x, k, 'descend', 'maxk', varargin{:});
|
|
end
|