I want to find the smallest 5 values in an integer vector of 10 integers. Not only the values but also their indices. Can anyone guide me please?
for example v = [0 5 1 3 2 6 0 9 8 7]
the answer should be [0 0 1 2 3] and their indices.
Thank you

 Akzeptierte Antwort

James Tursa
James Tursa am 15 Jun. 2011

1 Stimme

See the 2nd output of the sort function giving the original indexes of the sorted values.
[B,IX] = sort(A,...)

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Hilfe-Center und File Exchange

Produkte

Gefragt:

am 15 Jun. 2011

Kommentiert:

am 17 Jan. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by