필터 지우기
필터 지우기

Indexing a vector in a particular fashion

조회 수: 2 (최근 30일)
hmhuang
hmhuang 2021년 11월 21일
답변: Star Strider 2021년 11월 21일
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?

답변 (1개)

Star Strider
Star Strider 2021년 11월 21일
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
.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by