使用以下两个输出sort
:
% Example data Acc_Std = randi(10, 1,10); % Extract the smallest N elements N = 3; % Sort, while saving the original indices [B, indices] = sort(Acc_Std); % Now extract the N smallest elements smallest_N = B(1:N); % Check that they are indeed located at the % indices returned by sort() isequal(smallest_N, Acc_Std(indices(1:N)))
执行这个小脚本的结果:
ans = 1