MATLAB Answers

huda nawaf

remove equal items without loop

Asked by huda nawaf
on 28 Mar 2012

hi, I want to remove any two item are equal without loop x=[1 2 3 5]; y=[4 3 1 6 7]; I want the result be x=[2 5] y=[4 6 7] how do that? thanks

  0 Comments

Tags

Products

No products are associated with this question.

2 Answers

Answer by Wayne King
on 28 Mar 2012
 Accepted answer
   [~,inx,iny] = intersect(x,y);
   x(inx) = [];
   y(iny) = [];

  1 Comment

huda nawaf
on 28 Mar 2012

many many thanks


Answer by Andrei Bobrov
on 28 Mar 2012
x = setdiff(x,y)
y = setdiff(y,x)

  0 Comments


Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today