getting index of elements

1 回表示 (過去 30 日間)
Salvatore Mazzarino
Salvatore Mazzarino 2012 年 11 月 10 日
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 日
find(list==0)
  4 件のコメント
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 日
Perhaps one of these
index = find(g_counter == list(2))
index = find(g_counter == list(list==0))

カテゴリ

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