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
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.