Code covered by the BSD License  

Highlights from
findNsmallest

4.5

4.5 | 2 ratings Rate this file 7 Downloads (last 30 days) File Size: 3.22 KB File ID: #39727

findNsmallest

by

 

04 Jan 2013 (Updated )

Finds the N smallest values in the input. Very fast.

| Watch this File

File Information
Description

Example:
x = findNsmallest( [4 4 10 5 3 8], 3)

x =
4 4 3

Written in c, so the operation is fast. Type "mex findNSmallest.c" in matlab before use.

You might need a free compiler if it was not installed with your matlab:
http://www.mathworks.com/support/compilers/R2012b/win64.html

MATLAB release MATLAB 8.0 (R2012b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
06 Feb 2013 lu li

It would be perfect if returned values are in sorted order.

18 Jan 2013 Mattias Karlsson

As is discussed for findNlargest, this function is intended for cases when you are choosing a small number of values from a large pool. If you choose 5 values from a pool of a million, this function is about 40 times faster than if you sort.

06 Jan 2013 Renwen Lin  
Updates
07 Jan 2013

Added example to description

Contact us