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 Kommentare

madhan ravi
madhan ravi am 30 Aug. 2019
Expected result?
JL
JL am 30 Aug. 2019
c = [0 1 0
1 0 1];
Sorry to include it

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

madhan ravi
madhan ravi am 30 Aug. 2019

0 Stimmen

ix = ismember(a,b,'rows');
a(ix,:) % gives you the rows in a which is common to b and ~ix vice versa

3 Kommentare

JL
JL am 30 Aug. 2019
Is is possible to get this?
c = [0 1 0
1 0 1];
Did you see the comment?
a(~ix,:)
JL
JL am 30 Aug. 2019
great thanks!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Jos (10584)
Jos (10584) am 30 Aug. 2019

0 Stimmen

You can simply use setdiff with the rows option ...
c = setdiff(a,b,'rows')

Gefragt:

JL
am 30 Aug. 2019

Beantwortet:

am 30 Aug. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by