Array matching

1 回表示 (過去 30 日間)
Trader
Trader 2012 年 4 月 26 日
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.

回答 (1 件)

Geoff
Geoff 2012 年 4 月 26 日
child = A;
child(A ~= B) = 0;
  9 件のコメント
Geoff
Geoff 2012 年 5 月 2 日
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 2012 年 5 月 2 日
I frequently confuse humor and humerus. Therefore I thank you for your clarifications.
Is the OP still interested in the solution?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Type Identification についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by