Finding ALL the indicies that match a certain value

조회 수: 3 (최근 30일)
Abbi Hashem
Abbi Hashem 2018년 12월 10일
답변: Star Strider 2018년 12월 10일
Suppose I have a variable A= 4
and I have a vector B = [ 3 5 4 6 4 6 7 ]
I want to find the index of B that match A
that is , a vector with [ 3 , 5 ] since they are the third and 5th

답변 (1개)

Star Strider
Star Strider 2018년 12월 10일
Use the find function:
A = 4;
B = [ 3 5 4 6 4 6 7 ];
idx = find(B == A)
producing:
idx =
3 5

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by