finding mismatched elements ~ismember

2 ビュー (過去 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 Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by