Hints or tips when vectorizing ismember.

1 次查看(过去 30 天)
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 个评论
Daniel Shub
Daniel Shub 2013-4-21
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.

请先登录,再进行评论。

回答(0 个)

类别

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