Removing specific elements from array

조회 수: 11 (최근 30일)
ng jun Quan
ng jun Quan 2019년 4월 28일
댓글: ng jun Quan 2019년 4월 28일
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