Indexing a vector in a particular fashion

1 visualización (últimos 30 días)
hmhuang
hmhuang el 21 de Nov. de 2021
Respondida: Star Strider el 21 de Nov. de 2021
I have a vector: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
I want to index this vector in the following order: [9, 10, 7, 8, 5, 6, 3, 4, 1, 2]
How to do that?

Respuestas (1)

Star Strider
Star Strider el 21 de Nov. de 2021
Index it pretty much exactly as ot was written —
v = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
idx = [9, 10, 7, 8, 5, 6, 3, 4, 1, 2];
out = v(idx)
out = 1×10
9 10 7 8 5 6 3 4 1 2
.

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by