I have two array a=[1,2,3] and b=[2,3,4,5]
I need a array c=b\a. Here \ is the set subtract operation. result is as follows:
i.e.c=[4,5]
How to do that in matlab. Thanks in advance.

 채택된 답변

Matt Fig
Matt Fig 2012년 12월 12일
편집: Matt Fig 2012년 12월 12일

4 개 추천

a = 1:3;
b = 2:5;
c = setdiff(b,a)

추가 답변 (1개)

Vishal Rane
Vishal Rane 2012년 12월 12일

1 개 추천

Use
c = b(~ismember(b,a))
although there might be more simpler way to do this.

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by