Code covered by the BSD License  

Highlights from
Min/Max selection

Min/Max selection


Bruno Luong (view profile)


07 Apr 2009 (Updated )

Search for k smallest or largest elements in the array

function varargout = maxk(varargin)
% function res = MAXK(list, k)
% If LIST is a vector, MAXK returns in RES the K largest elements of LIST
%   RES is sorted in descending order
% [res loc] = MAXK(...)
%   Location of the largest elements: RES=LIST(LOC)
% If list is a matrix, MAXK operates along the first dimension
% Use MAXK(..., dim) to operate along the dimension dim
%     MAXK(..., dim, 'sorting', false) to disable the post-sorting step
%                                      (true by default)
% Author Bruno Luong <>
% Contributor: Matt Fig
% Last update: 07/April/2009
%              10/Jan/2010: possibility to disable post-sorting step

[nout{:}] = minmaxk(@maxkmex, varargin{:});

Contact us