5.0

5.0 | 1 rating Rate this file 175 downloads (last 30 days) File Size: 19.86 KB File ID: #23576

Min/Max selection

by Bruno Luong

 

07 Apr 2009 (Updated 11 Aug 2009)

Code covered by BSD License  

Search for k smallest or largest elements in the array

Download Now | Watch this File

File Information
Description

Using a partial quick-sort algorithm implemented with C-MEX. The complexity is O(n + k.log(k)), where n is the size of the array, and k is the number of elements to be selected.

Faster than SORT or multiple call of MIN/MAX for large size inputs.

Multidimensional capability supported

MATLAB release MATLAB 7.3 (R2006b)
Zip File Content  
Other Files
license.txt,
MinMaxSelection/buildInternal_mxArrayDef.m,
MinMaxSelection/Contents.txt,
MinMaxSelection/getmexopts.m,
MinMaxSelection/inplacecolumnmex.c,
MinMaxSelection/maxk.m,
MinMaxSelection/maxkmex.c,
MinMaxSelection/maxkmex.m,
MinMaxSelection/mink.m,
MinMaxSelection/minkmex.c,
MinMaxSelection/minkmex.m,
MinMaxSelection/minmax_install.m,
MinMaxSelection/minmaxk.m,
MinMaxSelection/releaseinplace.c,
MinMaxSelection/testminmax.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
28 Sep 2009 Dude25

That's look interesting.
How can I compile it?
When i try to install it with "minmax_install" i get the following error: "getmexopts [Bruno]: cannot open comopts.bat file".
How does this file have to look like?

thx
marcello

28 Sep 2009 Bruno Luong

Marcello,

Do you have MEX setup? If not, type he following in command line:
>> mex -setup

If it's already installed you have to locate mexopts.bat file somewhere under the directory $MATLABROOT (where the Matlab is installed), then modify OPTPATH variable in line #8 and line #12 of GETMEXOPTS.

then try installation again.

Bruno

03 Oct 2009 Rencheng Á

Thanks! It is very useful!

Please login to add a comment or rating.
Updates
07 Apr 2009

Bug correction (for k=0)
Do not compute unnecessary location indexes when not required.

24 May 2009

Supported sparse input

26 Jun 2009

handle arrays with NaN

29 Jun 2009

Correct bug + inplace engine

11 Aug 2009

Correct bug: cleanup the inplace variable when MEX issues an error (otherwise computer might crash)

Tag Activity for this File
Tag Applied By Date/Time
min Bruno Luong 07 Apr 2009 11:06:25
max Bruno Luong 07 Apr 2009 11:06:25
sorting Bruno Luong 07 Apr 2009 11:06:25
selection Bruno Luong 07 Apr 2009 11:06:26
partial sort Bruno Luong 07 Apr 2009 11:06:26
quicksort Bruno Luong 07 Apr 2009 11:06:26
min Ayesha 25 Jun 2009 01:08:47
kthvalue Jos 29 Jun 2009 11:03:01
max Jesus 02 Oct 2009 05:20:09
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com