MATLAB Answers

How to find the Union of two matrices with the same column size?

40 views (last 30 days)
ha ha
ha ha on 19 Aug 2017
Answered: Ryan Klots on 19 Aug 2017
I have two matrices of different sizes: say A(n,2) and B(m,2). How to find the "Union" or "Intersection" of these two matrices?
*Hope the result will be: C(k,2)= A ⋃ B .....and D(p,2) =A ∩ B
**Thanks so much,

  0 Comments

Sign in to comment.

Accepted Answer

Ryan Klots
Ryan Klots on 19 Aug 2017
It looks like the union and intersect functions might come in handy here.
Try
C = union(A, B, 'rows');
D = intersect(A, B, 'rows');

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Tags

No tags entered yet.