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];

回答(1 个)

Azzi Abdelmalek
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)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by