Comparing two arrays to see if any similar values
Mostrar comentarios más antiguos
For the two arrays:
Array A:
100 9 2 0
100 14 4 0
100 14 4 0
100 15 5 0
100 18 5 0
100 45 7 0
100 45 9 0
100 46 18 0
100 46 22 0
and, Array B:
100 18 2
100 18 2
100 18 2
100 18 5
It can be seen that Array A(4,1:3) is the same as Array B(4,1:3)
How can I write a script which, in this instance of these two values being the same a "1" could be written in the fourth column of Array A (A(4,4))?
Also, I want this to work if the 2nd and 3rd column value of Array A is 1 value different (plus or minus) from Array B. e.g. if Array B(4,1:3) was 100 19 4, it would still warite a "1" in the fourth column of Array A (as only 1 value different)
Thanks for any help :)
Respuestas (1)
Sean de Wolski
el 30 de Dic. de 2014
doc ismember
doc intersect
Look at the 'rows' option.
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!