when i run this code:
a=[1 1 2];
b=[1];
setdiff(a,b)
i get this:
>> c
ans =
2
but I want this:
>> c
ans =
1 2
What should I do to fix this ?

 採用された回答

Torsten
Torsten 2018 年 10 月 23 日

1 投票

https://de.mathworks.com/matlabcentral/answers/406227-excluding-one-vector-from-another-vector-with-repetition

その他の回答 (1 件)

KSSV
KSSV 2018 年 10 月 23 日

0 投票

B2 = union(a,b)

1 件のコメント

IBM watson
IBM watson 2018 年 10 月 23 日
Yes but algorithm should be able do this in a loop. I cant check it every time. Because if b was b=[2] then i get wrong results.

サインインしてコメントする。

質問済み:

2018 年 10 月 23 日

回答済み:

2018 年 10 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by