Removing specific elements from array

12 次查看(过去 30 天)
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
>> a = [1,1,3,5];
>> c = [1,5];
>> [X,Y] = ismember(c,a);
>> a(Y(X)) = []
a =
1 3

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Types 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by