How to do set subtraction

101 ビュー (過去 30 日間)
Mohammad Golam Kibria
Mohammad Golam Kibria 2012 年 12 月 12 日
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 日
a = 1:3;
b = 2:5;
c = setdiff(b,a)

その他の回答 (1 件)

Vishal Rane
Vishal Rane 2012 年 12 月 12 日
Use
c = b(~ismember(b,a))
although there might be more simpler way to do this.

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by