Borrar filtros
Borrar filtros

check two matrix if its same display the matched value

1 visualización (últimos 30 días)
Matlab111
Matlab111 el 13 de Jul. de 2014
Respondida: Jan el 13 de Jul. de 2014
i'm checking this two matrix a,b if it's same element than display the matched value and again the matched value only should get deleted and than it that should display what are all the values din't matched with 'b'(it means after deleting the remaining matrix should display).
a=[1 2 3 4 5 6 7];
b=[3 1 2 4 9 8 4];
Note: i'm compering 'a' with 'b'.
answer should be
c=[9 8];

Respuesta aceptada

Jan
Jan el 13 de Jul. de 2014
a = [1 2 3 4 5 6 7];
b = [3 1 2 4 9 8 4];
c = b(~ismember(b, a))

Más respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 13 de Jul. de 2014
Editada: Azzi Abdelmalek el 13 de Jul. de 2014
a=[1 2 3 4 5 6 7];
b=[3 1 2 4 9 8 4]
out=setdiff(b,a,'stable')
  3 comentarios
Azzi Abdelmalek
Azzi Abdelmalek el 13 de Jul. de 2014
Try this
a=[1 2 3 4 5 6 7];
b=[3 1 2 4 9 8 4]
[ii,jj]=setdiff(b,a)
[~,idx]=sort(jj)
out=ii(idx)
Matlab111
Matlab111 el 13 de Jul. de 2014
ya i'm getting thank you

Iniciar sesión para comentar.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by