difference of two vector

1 view (last 30 days)
dario cecchetti
dario cecchetti on 30 May 2017
Commented: Star Strider on 30 May 2017
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.

Accepted Answer

Star Strider
Star Strider on 30 May 2017
One approach:
A=[0 0 1 1];
B=[0];
ia = ismember(A,B);
C = A(~ia)
C =
1 1
  2 Comments
dario cecchetti
dario cecchetti on 30 May 2017
Thank you very much!!!!!!!!
Star Strider
Star Strider on 30 May 2017
As always, my pleasure!

Sign in to comment.

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!