hello.can any one tell me how can I find 5 lowest values in a vector without replacement?
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
Azzi Abdelmalek
on 30 Jul 2016
Edited: Azzi Abdelmalek
on 30 Jul 2016
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 Comments
Image Analyst
on 30 Jul 2016
Another way to "thank" someone is to "Accept" their answer to give them reputation points.
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!