hello.can any one tell me how can I find 5 lowest values in a vector without replacement?
1 次查看(过去 30 天)
显示 更早的评论
for example: A=[3 4 5 1 2 7 3 9 0 1 4 5 7 3 0 8]; and the answer is:B=[1 2 0 1 0];
0 个评论
回答(1 个)
Azzi Abdelmalek
2016-7-30
编辑:Azzi Abdelmalek
2016-7-30
A=[3 4 5 1 2 7 3 9 0 1 4 5 7 3 0 8]
[ii,jj]=sort(A)
idx=sort(jj(1:5))
out=A(idx)
2 个评论
Image Analyst
2016-7-30
Another way to "thank" someone is to "Accept" their answer to give them reputation points.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!