Code covered by the BSD License
Mattias Karlsson (view profile)
04 Jan 2013
07 Jan 2013)
Finds the N smallest values in the input. Very fast.
Watch this File
x = findNsmallest( [4 4 10 5 3 8], 3)
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:
It would be perfect if returned values are in sorted order.
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.
Added example to description