2

如何获得n一维数组的最小元素

例子

A = [29, 60, 96, 43, 69, 53];
n=3;
%so B will be like this
B = [29 43 53];
4

1 回答 1

4

尝试这个:

B = sort(A);    %# sort in ascending order
B = B(1:n);     %# take the first N-values
于 2013-04-24T12:41:11.020 回答