MATLAB Answers

Neesha

Setdiff n intersect question

Asked by Neesha
on 21 Aug 2014
Latest activity Commented on by Neesha
on 22 Aug 2014

Hi,

I have two dataset.

1)

  • Shop# - floor#
  • 321 - 4
  • 321 - 2
  • 321 - 3
  • 322 - 0
  • 322 - 2

2)

  • shop# - floor#
  • 322 - 1
  • 322 - 0
  • 322 - 2

if i do intersect of those two, i expect following, but i get just first row. WHy? 3)

  • shop# - floor#
  • 322 - 0
  • 322 - 2

  0 Comments

Products

No products are associated with this question.

1 Answer

Answer by Guillaume
on 21 Aug 2014
 Accepted answer
>> a=[321 4;321 2;321 3;322 0;322 2];
>> b=[322 1;322 0;322 2];
>> intersect(a, b, 'rows')
ans =
   322     0
   322     2

  8 Comments

Neesha
on 21 Aug 2014

ok, so i had to round floor number to get it to work... thanks.

Matt J
on 22 Aug 2014

@Neesha, if you got it work, you should accept Guillaume's answer

Neesha
on 22 Aug 2014

i accepted it, but i did not end up using 'rows', it worked without it as problem was coming from somewhere else


Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today