How to fined specific Kth values of an vector with n element

6 Ansichten (letzte 30 Tage)
Idris Oussalah
Idris Oussalah am 23 Feb. 2020
Beantwortet: Image Analyst am 23 Feb. 2020
Supose i have a vector a = [ 2 4 6 8 10] and i want to extract the 1st , 3rd and 5th elements so i want to use a vector b = [1 3 5] and get the answer back as : c = [2 6 10]; how do i do that?
Thanks!

Antworten (1)

Image Analyst
Image Analyst am 23 Feb. 2020
Use b as a linear index for a:
a = [ 2 4 6 8 10]
b = [1 3 5]
c = a(b)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by