from
nth_element
by Peter Li MEX wrap of C++ nth_element. Plus fast_median, a faster median function. In-place and parallel.
fast_median_ip.m
%FAST_MEDIAN_IP In-place editing version of FAST_MEDIAN
% MEDIANS = FAST_MEDIAN(ARR)
%
% USE AT YOUR OWN RISK!
%
% See FAST_MEDIAN for general notes.
%
% This version edits the array in-place, so after you have run it your
% original array will have changed. This is counter to standard Matlab
% style. It also requires calling undocumented Mathworks internals, so is
% not guaranteed to work at all on all Matlab versions and should be used
% at your own risk.
%
% Version 0.85
% Peter H. Li 26-JUN-2013
% As required by MatLab Central FileExchange, licensed under the FreeBSD License