Compare 2 vectors together

2 views (last 30 days)
Steven
Steven on 9 Sep 2012
Hi,
Let's say we have 2 vectors of different lenght, values (but there's not 2 values identical in the same vector) and not sorted. What's the quickest way to have all the values that are the same. For example :
a = [0 5 4 88 18 26 33]
b = [2 4 17 3 26]
c = someFunction(a,b);
==> c = [4 26];
Thank you

Accepted Answer

Dishant Arora
Dishant Arora on 9 Sep 2012
intersect(a,b);

More Answers (0)

Categories

Find more on Shifting and Sorting Matrices 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!