remove equal items without loop

1 Ansicht (letzte 30 Tage)
huda nawaf
huda nawaf am 28 Mär. 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

Akzeptierte Antwort

Wayne King
Wayne King am 28 Mär. 2012
[~,inx,iny] = intersect(x,y);
x(inx) = [];
y(iny) = [];

Weitere Antworten (1)

Andrei Bobrov
Andrei Bobrov am 28 Mär. 2012
x = setdiff(x,y)
y = setdiff(y,x)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by