필터 지우기
필터 지우기

How to index from three vectors?

조회 수: 3 (최근 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 CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by