Comparing two arrays to see if any similar values
Show older comments
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 :)
Answers (1)
Sean de Wolski
on 30 Dec 2014
doc ismember
doc intersect
Look at the 'rows' option.
Categories
Find more on Operators and Elementary Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!