How can I get the smallest n elements of a 1D array
example
A = [29, 60, 96, 43, 69, 53];
n=3;
%so B will be like this
B = [29 43 53];
How can I get the smallest n elements of a 1D array
example
A = [29, 60, 96, 43, 69, 53];
n=3;
%so B will be like this
B = [29 43 53];
Try this:
B = sort(A);    %# sort in ascending order
B = B(1:n);     %# take the first N-values