Clear Filters
Clear Filters

Array matching

7 views (last 30 days)
Trader
Trader on 26 Apr 2012
I have 2 arrays that i'd like to compare values and create a child that contains matching values (and I'd like to do this the fastest way possible).
Example:
A = [1;0;-1;0;0;0;1]
B = [0;1;-1;0;1;0;1]
child = [0;0;-1;0;0;0;1]
Your help is greatly appreciated! Thank you.

Answers (1)

Geoff
Geoff on 26 Apr 2012
child = A;
child(A ~= B) = 0;
  9 Comments
Geoff
Geoff on 2 May 2012
Hey it even fooled me... I was under a bit of pressure and lost my sense of humour for a couple of days. =)
Jan
Jan on 2 May 2012
I frequently confuse humor and humerus. Therefore I thank you for your clarifications.
Is the OP still interested in the solution?

Sign in to comment.

Categories

Find more on Data Type Identification in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!