How to index from three vectors?

1 回表示 (過去 30 日間)
Chameleon17
Chameleon17 2018 年 2 月 9 日
回答済み: Mohammed Bahubayl 2018 年 2 月 9 日
Hi,
I think this is quite simple but I'm missing something.
I have three vectors
A = [0 1 0 1 0 0]'
B = [0 1 1 0 0 0]'
C = [0 1 0 1 0 0]'
I want to index to get the location where there is a 1 in all vectors and the same so I would want this to tell me 2 as that is the location in all three that is equal to 1. I know find will work for two vectors but how to you write it for three?
Thanks for any help.

採用された回答

Birdman
Birdman 2018 年 2 月 9 日
find(A==1 & B==1 & C==1)
  1 件のコメント
Adam
Adam 2018 年 2 月 9 日
or just
find( A & B & C )
if they are just 0s and 1s

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

その他の回答 (1 件)

Mohammed Bahubayl
Mohammed Bahubayl 2018 年 2 月 9 日
find(sum([A,B,C],2)==3)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by