필터 지우기
필터 지우기

How to find vector indexes without for loops

조회 수: 1 (최근 30일)
Hamid Bakht
Hamid Bakht 2016년 11월 30일
댓글: David Goodmanson 2016년 11월 30일
i have a vector matrix for example [20,3,56,7,8,96,52,22] and i have another value x=8. now i wanna find the index number of x in that vector without using for or while loop thank you for your help
  댓글 수: 1
David Goodmanson
David Goodmanson 2016년 11월 30일
Hi Hamid, take a look at the 'find' function

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

답변 (1개)

Guillaume
Guillaume 2016년 11월 30일
[~, index] = ismember(8, [20, 3, 56, 7, 8, 96, 52, 22]);
or
index = find([20, 3, 56, 7, 8, 96, 52, 22] == 8);

카테고리

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