Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit:

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


huda nawaf



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

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


Andrei Bobrov

Contact us