returning differences between two matrices

48 visualizaciones (últimos 30 días)
Zachary Noll
Zachary Noll el 13 de Sept. de 2018
Respondida: Paolo el 13 de Sept. de 2018
I am relatively new to matlab (saw lots of people bashed for asking simple questions..) I need to compare two matrices, and to return true if they are the same. If they aren't identical, I need to have the code return all of the indeces that were not equal:
for instance, I have matrices A = [1,2,3,4,5] and B = [1,2,4,4,5]. I need the code to return either the index of the unequal variable or some other indicating factor.
Thanks!

Respuesta aceptada

madhan ravi
madhan ravi el 13 de Sept. de 2018
Editada: madhan ravi el 13 de Sept. de 2018
Index = find(A~=B)

Más respuestas (2)

Matt J
Matt J el 13 de Sept. de 2018
indicator = (A~=B);

Paolo
Paolo el 13 de Sept. de 2018
You can use setdiff:
[~,ia] = setdiff(A,B)

Categorías

Más información sobre Matrices and Arrays 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