difference of two vector

조회 수: 1 (최근 30일)
dario cecchetti
dario cecchetti 2017년 5월 30일
댓글: Star Strider 2017년 5월 30일
Hi everybody, I would like to know how to solve the following problem.
A=[0 0 1 1]
B=[0]
where B has got only one component. ex. My goal is to delete the components A(1 2) automatically and obtaining
C=[1 1].
The 'A' vector is obtained afther for loop,but I don't know how many components are zero and one, while 'B' is known. My goal is to delete the components A(1 2) automatically and obtaining C=[1 1].
Thank you.

채택된 답변

Star Strider
Star Strider 2017년 5월 30일
One approach:
A=[0 0 1 1];
B=[0];
ia = ismember(A,B);
C = A(~ia)
C =
1 1
  댓글 수: 2
dario cecchetti
dario cecchetti 2017년 5월 30일
Thank you very much!!!!!!!!
Star Strider
Star Strider 2017년 5월 30일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by