Select a certain number of mine Vector Members in MATLAB

2 Ansichten (letzte 30 Tage)
lech king
lech king am 6 Okt. 2020
Kommentiert: lech king am 6 Okt. 2020
Hi
I have a 40 x 1 vector. I want to find the location of 20 smaller components of this vector. The position of these members is considered.
Thanks for your guidance

Akzeptierte Antwort

KSSV
KSSV am 6 Okt. 2020
Let v be your vector. You can arrange them from small to big order i.e in ascending order and then pick first twenty elements.
[val,idx] = sort(v) ;
val(1:20) % values
idx(1:20) % indices
  3 Kommentare
KSSV
KSSV am 6 Okt. 2020
You already have the indices in your hand as idx which corresponds to original vector. This is not a problem. The positions are according to vector v.
lech king
lech king am 6 Okt. 2020
Thank you very very much

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by