Hints or tips when vectorizing ismember.

1 回表示 (過去 30 日間)
Ale Kaszynski
Ale Kaszynski 2013 年 4 月 21 日
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 Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by