Difference between two Vectors
Mostrar comentarios más antiguos
I have two arrays
A = [-1 1 -2 1 -1 1 -1 -2 -1 1];
B = [-1 1 1 -1 1 -1 -1 1];
and i am wanting to find all of the values in A that do not appear in B.
So the answer would appear that
values = [-2 -2 ] % values that are in A but not B
index = [3 8] % location of 'values' in A
thanks
1 comentario
connor
el 11 de Nov. de 2013
Respuesta aceptada
Más respuestas (1)
Andrei Bobrov
el 9 de Nov. de 2013
ii = ~ismember(A,B)
values = A(ii)
index = find(ii)
Categorías
Más información sobre Operators and Elementary Operations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!