finding the position of values in a matrix

조회 수: 3 (최근 30일)
sampath kumar punna
sampath kumar punna 2019년 10월 30일
댓글: sampath kumar punna 2019년 10월 30일
i have set
X=[
12 14
1 2
12 4
6 14
12 18
12 4
1 2]
Y=[
1 2
1 2
6 14
12 4]
can i get the position of Y elements in X matrix as the number are repeated its hard for me to find using code normal code. can any one please help me.

답변 (1개)

galaxy
galaxy 2019년 10월 30일
Try
[~,idx]=setdiff(X,Y,'rows');
idx_rows=setdiff(1:size(X,1),idx);
idx_rows =
2 3 4 6 7
  댓글 수: 3
galaxy
galaxy 2019년 10월 30일
because X and Y array has same value, if you want to find only one, you need use unique function
sampath kumar punna
sampath kumar punna 2019년 10월 30일
yes X and Y have same values but Y is not having all values of X only few values are in Y, so for those some values in Y, what is the position in X.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by