필터 지우기
필터 지우기

corresponding index of an element

조회 수: 1 (최근 30일)
Salvatore Mazzarino
Salvatore Mazzarino 2012년 11월 10일
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
Azzi Abdelmalek
Azzi Abdelmalek 2012년 11월 10일
your question is not clear

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

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2012년 11월 10일
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
Salvatore Mazzarino
Salvatore Mazzarino 2012년 11월 10일
Maybe you had resolved my problem.One minute I check if everything work
Salvatore Mazzarino
Salvatore Mazzarino 2012년 11월 10일
Ok problem solved...thanks so much...

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

추가 답변 (1개)

José-Luis
José-Luis 2012년 11월 10일
편집: José-Luis 2012년 11월 10일
idx = find(g_counter == 0 & list == 0);
or
idx = find(~g_counter & ~list);
or
idx = find(g_counter - list == g_counter + list);
  댓글 수: 1
Salvatore Mazzarino
Salvatore Mazzarino 2012년 11월 10일
thanks you too for your help.very nice :-)

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

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by