View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

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




04 Jan 2013 (Updated )

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

| Watch this File

File Information

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:

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

lu li (view profile)

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.

Comment only
06 Jan 2013 Renwen Lin

07 Jan 2013 1.1

Added example to description

Contact us