Removing specific elements from array

Lets assume i have
a = [1 1 3 5];
c = [1 5];
i want to remove c from a and the output should be a = [1 3]
a = setdiff(a,c) %this works but it removes both the '1' .

 採用された回答

Stephen23
Stephen23 2019 年 4 月 28 日
編集済み: Stephen23 2019 年 4 月 28 日

1 投票

>> a = [1,1,3,5];
>> c = [1,5];
>> [X,Y] = ismember(c,a);
>> a(Y(X)) = []
a =
1 3

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Types についてさらに検索

質問済み:

2019 年 4 月 28 日

コメント済み:

2019 年 4 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by