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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by