Retrive index of an element from vector.

조회 수: 2 (최근 30일)
charu shree
charu shree 2023년 5월 15일
답변: charu shree 2023년 5월 15일
Hello all, I am having two vectors of same dimension as shown:
sr = [1,2,2,2,2,3,3,3,3,4,4,5,6,6,6,7]; % various possible Source
ta = [2,1,3,6,8,2,4,6,7,3,6,6,3,4,5,3]; % various possible targets
We access the elements in 'sr' by 'i' and 'ta' by 'j'. My query is how can we get the index of elements in these vector, for e.g., when i = 2 and j = 3.
Any help in this regard will be highly appreciated.
  댓글 수: 1
Mathieu NOE
Mathieu NOE 2023년 5월 15일
if I understand correctly, i and j are the indexes of your vectors but we need a logic / rule to define i and j
your question is unclear or incomplete, what do you want to achieve ?

댓글을 달려면 로그인하십시오.

채택된 답변

charu shree
charu shree 2023년 5월 15일
Hello all, I understood how this can be done. It is shown below:
index = find((sr==3) & (ta==7));
So index will give value 9.

추가 답변 (0개)

카테고리

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