reduce rows of a due to b

1 回表示 (過去 30 日間)
JL
JL 2019 年 8 月 30 日
回答済み: Jos (10584) 2019 年 8 月 30 日
Hi everyone, I have 2 matices, A and B
a = [0 1 0
0 1 1
1 0 1
1 1 1];
b =[1 1 1
0 1 1];
Is it possible to reduce a using b?
  2 件のコメント
madhan ravi
madhan ravi 2019 年 8 月 30 日
Expected result?
JL
JL 2019 年 8 月 30 日
c = [0 1 0
1 0 1];
Sorry to include it

サインインしてコメントする。

採用された回答

madhan ravi
madhan ravi 2019 年 8 月 30 日
ix = ismember(a,b,'rows');
a(ix,:) % gives you the rows in a which is common to b and ~ix vice versa
  3 件のコメント
madhan ravi
madhan ravi 2019 年 8 月 30 日
Did you see the comment?
a(~ix,:)
JL
JL 2019 年 8 月 30 日
great thanks!

サインインしてコメントする。

その他の回答 (1 件)

Jos (10584)
Jos (10584) 2019 年 8 月 30 日
You can simply use setdiff with the rows option ...
c = setdiff(a,b,'rows')

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by