finding mismatched elements ~ismember

조회 수: 3 (최근 30일)
Lalit Patil
Lalit Patil 2012년 12월 25일
A = [1 2 3;2 3 4;3 4 5;4 5 6;5 6 7;6 7 8;7 8 9]
B = [2 3 4;6 7 8]
flag = ~ismember(A,B,'rows');
index = find(flag);
q = A(index(flag))
The error is
??? Index exceeds matrix dimensions.
and The index finds only first elements of each row. The remaining two should also find it.. So, how to do it.?
  댓글 수: 2
Matt J
Matt J 2012년 12월 25일
The index finds only first elements of each row. The remaining two should also find it.
This is not clear. Write explicitly what you want "index" and "q" to be.
Andrei Bobrov
Andrei Bobrov 2012년 12월 25일
q = A(flag,:);
or
q = A(index,:);

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

채택된 답변

Matt J
Matt J 2012년 12월 25일
q = setdiff(A,B,'rows')

추가 답변 (1개)

Walter Roberson
Walter Roberson 2012년 12월 25일
Are these integers or numbers with fractions? If they are numbers with fractions then you cannot use ismember() in most cases.

카테고리

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