"setdiff" comand usage ?

조회 수: 2 (최근 30일)
IBM watson
IBM watson 2018년 10월 23일
답변: Torsten 2018년 10월 23일
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일
https://de.mathworks.com/matlabcentral/answers/406227-excluding-one-vector-from-another-vector-with-repetition

추가 답변 (1개)

KSSV
KSSV 2018년 10월 23일
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.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by