Hints or tips when vectorizing ismember.

1 visualización (últimos 30 días)
Ale Kaszynski
Ale Kaszynski el 21 de Abr. de 2013
For matrix A, I would like to output all the values of each row where a unique value of A occurs without using a loop, excluding the unique value being tested.
For example
A= [1,2,3,4,5,6,7,8; 1,3,4,5,6,8,9,10; 8,10,13,14,18,20,21,22]
would produce...
C{1}=[2,3,4,5,6,7,8,9,10]; C{2}=[1,3,4,5,6,7,8]; C{3}=[1,2,4,5,6,7,8,9,10]; C{4}=[1,3,4,5,6,8,9,10]; ... C{8}=[1,2,3,4,5,6,7,9,10,13,14,18,20,21,22]; and so on...
Thanks in advance for any help!
  1 comentario
Daniel Shub
Daniel Shub el 21 de Abr. de 2013
It is not clear what the algorithm is supposed to do. I seem no relationship between your A double matrix and your C cell array. Finally, why do you want to avoid loops? Wouldn't it be better to ask for efficient code that is easy to understand and maintain? Given you don't have a working algorithm yet asking for efficient code seems like a case of premature optimization.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by