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 Commenti

madhan ravi
madhan ravi il 30 Ago 2019
Expected result?
c = [0 1 0
1 0 1];
Sorry to include it

Accedi per commentare.

 Risposta accettata

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

3 Commenti

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

Accedi per commentare.

Più risposte (1)

Jos (10584)
Jos (10584) il 30 Ago 2019
You can simply use setdiff with the rows option ...
c = setdiff(a,b,'rows')

Richiesto:

JL
il 30 Ago 2019

Risposto:

il 30 Ago 2019

Community Treasure Hunt

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

Start Hunting!

Translated by