remove equal items without loop

1 visualizzazione (ultimi 30 giorni)
huda nawaf
huda nawaf il 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

Risposta accettata

Wayne King
Wayne King il 28 Mar 2012
[~,inx,iny] = intersect(x,y);
x(inx) = [];
y(iny) = [];

Più risposte (1)

Andrei Bobrov
Andrei Bobrov il 28 Mar 2012
x = setdiff(x,y)
y = setdiff(y,x)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by