corresponding index of an element

1 vue (au cours des 30 derniers jours)
Salvatore Mazzarino
Salvatore Mazzarino le 10 Nov 2012
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?
  1 commentaire
Azzi Abdelmalek
Azzi Abdelmalek le 10 Nov 2012
your question is not clear

Connectez-vous pour commenter.

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 10 Nov 2012
Maybe you want this
g_counter=[1 0 2 2 0]
list=[1 2 3 0 0]
idx=intersect(find(g_counter==0),find(list==0))
  2 commentaires
Salvatore Mazzarino
Salvatore Mazzarino le 10 Nov 2012
Maybe you had resolved my problem.One minute I check if everything work
Salvatore Mazzarino
Salvatore Mazzarino le 10 Nov 2012
Ok problem solved...thanks so much...

Connectez-vous pour commenter.

Plus de réponses (1)

José-Luis
José-Luis le 10 Nov 2012
Modifié(e) : José-Luis le 10 Nov 2012
idx = find(g_counter == 0 & list == 0);
or
idx = find(~g_counter & ~list);
or
idx = find(g_counter - list == g_counter + list);
  1 commentaire
Salvatore Mazzarino
Salvatore Mazzarino le 10 Nov 2012
thanks you too for your help.very nice :-)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by