n lowest values of a series
Show older comments
Hello, I'd like to find the n lowest values of a series of datas. "min" fonction does not seem to propose this option. I could use a loop of course, bur I'd like to find a fonction that could do that in 1 time if possible. Thank you for your help Christophe
Accepted Answer
More Answers (3)
Wayne King
on 29 Mar 2012
You can use sort() with the 'ascend' option.
% find smallest 5 values
n = 5;
x = randn(100,1);
y = sort(x,'ascend');
y = y(1:n)
Christophe
on 30 Mar 2012
0 votes
Christophe
on 30 Mar 2012
Categories
Find more on Solver Outputs and Iterative Display in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!