Find first common element in 2 vectors
12 views (last 30 days)
Show older comments
I have 2 vectors, A and B, with identical values but in different orders. How do I find the first common element between them? For example, I have 2 vectors as shown below. How would I return the value "25"?
A = [10 25 36 41 53]
B = [53 41 25 10 36]
Thanks in advance for any help!
4 Comments
Matt J
on 4 Apr 2022
I want index 25 because it is the first common index that is smallest in the two vectors.
No, 10 is smaller than 25.
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Descriptive Statistics 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!