필터 지우기
필터 지우기

find index of an arry in matlab

조회 수: 2 (최근 30일)
Rica
Rica 2019년 8월 12일
댓글: Rica 2019년 8월 12일
I have a big array and i want to find the index of the element of an array in the big array.
I know this could be easily solves with functions such find or ismember. But my goal is to give the index of the first number in the case when the the number is present more than one time in the big array like the numbers 2.2, 5.1, 6 and 7.
e.g
BigArray=[1 2 2.2 3 2.2 5 5.1 5.1 6 6 7 7.........]
ArryToBeFound=[1 2 2.2 5.1 6 7]
Solution:
index=[1 2 3 7 9 11]
Do you have any idea how to solve this?
Thank you

채택된 답변

Guillaume
Guillaume 2019년 8월 12일
ismember is indeed the functio to use:
[~, where] = ismember(ArrayToBeFound, BigArray)
where is the index of the 1st element where the element is found, or 0, if not found. ismember guarantees that it's always the first index.
  댓글 수: 1
Rica
Rica 2019년 8월 12일
next time i should read the documentation of ismember ;-)

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by