Determining the difference between two vectors
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
osman yurdakul
el 24 de Mzo. de 2011
Comentada: Anu Shivalinga
el 29 de Jul. de 2022
hello friends,
i have to find error between 2 array. i sent a data from transmitter to receiver.
data transmitted is;
td = [1 1 1 0 0 0 1 1 0 1 0 1 1 0 0];
and the data received is;
rd = [0 1 1 0 1 0 1 1 0 1 0 1 1 0 1];
and the number of error is 3 as it is seen above
but how can i find the error number by matlab code?..
Thanks for your helps.
0 comentarios
Respuesta aceptada
Más respuestas (3)
Matt Fig
el 24 de Mzo. de 2011
Expanding on Paulo's answer, to get the logical index locations of the errors, do this:
locs = td~=rd
now to find out how many there are, I would use
errornumber = sum(locs) % Or just sum(td~=rd) if locs not needed.
If you need the linear index number of the errors, then use FIND, as Paulo shows.
2 comentarios
Anu Shivalinga
el 29 de Jul. de 2022
Hello, this works perfect. Thanks. But what if sizes of 2 arrays are not equal? How to find the mismatch between those?
Paulo Silva
el 24 de Mzo. de 2011
yet another way
sum((td & rd | (~td & ~rd))==0)
even more simple
sum(~((td & rd | (~td & ~rd))))
even better
sum(xor(td,rd))
0 comentarios
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!