how to create a vector with known indices numbers

조회 수: 1 (최근 30일)
Melissa Jones
Melissa Jones 2021년 10월 19일
댓글: Melissa Jones 2021년 10월 19일
I have
vector = [1 3 4 6 7 7 8 90 8]
positions = [1 5 8]
How can I write a new_vector having the same lentgh as vector positions and containing the numbers of vector in the corresponding positions?

채택된 답변

Adam
Adam 2021년 10월 19일
result = vector( positions );
will give you this, if what you mean is you want the numbers from those positions of vector rather than that you want them in those positions of the result vector too.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by