getting index of elements

I have two vectors
g_vector = [2 0]
list = [3 0]
I would get the index of elements of g_vector that have their index in list matrix setted to 0. How can I do?
If I do
g_counter(list == 0)
I get 0 element of g_vector but I would have returned index 2 corresponding to the index of 0 in g_vector

답변 (2개)

Matt J
Matt J 2012년 11월 10일

0 개 추천

find(list==0)

댓글 수: 4

Salvatore Mazzarino
Salvatore Mazzarino 2012년 11월 10일
No it is not what I asked. The corresponding element of g_vector matrix has to be 0. In this way I don't know if the elements is 0 or not
Salvatore Mazzarino
Salvatore Mazzarino 2012년 11월 10일
편집: Salvatore Mazzarino 2012년 11월 10일
What I mean is to create a way to do this
in list matrix we have 3 and 0. select index 2 of list matrix. Now I would get the index of g_vector that have index 2 and have also 0 as element
Salvatore Mazzarino
Salvatore Mazzarino 2012년 11월 10일
편집: Salvatore Mazzarino 2012년 11월 10일
let me explain better
I have two vectors
g_counter = [2 0]
and
list = [3 0]
I would get the indices of all the elements belong to g_counter that have their position setted to zero and the corresponding position of list vector has to be setted to 0.
For instance with the given vectors I would get 2 as index. How can I do?
Matt J
Matt J 2012년 11월 10일
find(g_counter==0 & list==0)

댓글을 달려면 로그인하십시오.

Image Analyst
Image Analyst 2012년 11월 10일

0 개 추천

Perhaps one of these
index = find(g_counter == list(2))
index = find(g_counter == list(list==0))

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

질문:

2012년 11월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by