location of logical matrix

6 visualizaciones (últimos 30 días)
Cside
Cside el 22 de Ag. de 2019
Comentada: madhan ravi el 22 de Ag. de 2019
Hi I have a 10 x 2 logical matrix and I would need to find out the location of the rows which both columns are ones i.e 1 1.
May I know how I may write for this? Thank you!

Respuesta aceptada

madhan ravi
madhan ravi el 22 de Ag. de 2019
Editada: madhan ravi el 22 de Ag. de 2019
Since you have a logical matrix it’simply:
ix=all(matrix ,2); % logical indexing is efficient
Wanted=find(ix)
  6 comentarios
Cside
Cside el 22 de Ag. de 2019
thank you madhan for being so clear with your answer :)
madhan ravi
madhan ravi el 22 de Ag. de 2019
While learning always visualize with a simple and short example to understand what's going on.

Iniciar sesión para comentar.

Más respuestas (1)

KSSV
KSSV el 22 de Ag. de 2019
Read about ismember
idx = round(rand(10,2)) ;
vec = [1 1] ;
[c,ia] = ismember(idx,vec,'rows') ;
iwant = find(c) ;
idx(c,:)
idx(iwant,:)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by