reduce rows of a due to b

3 visualizaciones (últimos 30 días)
JL
JL el 30 de Ag. de 2019
Respondida: Jos (10584) el 30 de Ag. de 2019
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 comentarios
madhan ravi
madhan ravi el 30 de Ag. de 2019
Expected result?
JL
JL el 30 de Ag. de 2019
c = [0 1 0
1 0 1];
Sorry to include it

Iniciar sesión para comentar.

Respuesta aceptada

madhan ravi
madhan ravi el 30 de Ag. de 2019
ix = ismember(a,b,'rows');
a(ix,:) % gives you the rows in a which is common to b and ~ix vice versa
  3 comentarios
madhan ravi
madhan ravi el 30 de Ag. de 2019
Did you see the comment?
a(~ix,:)
JL
JL el 30 de Ag. de 2019
great thanks!

Iniciar sesión para comentar.

Más respuestas (1)

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

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by