matlab - Opposite indices when using find-function -


i searched lot in google didnt find answer did me without reducing performance.

i have matrice , b of same size different values. want filter:

  1. indices=find(a<5 & b>3)

    • a(indices)=
    • b(indices)=
  2. now want apply function on indices -> indices_2=find(a>=5 | b<=3) without using find function on whole matrices a , b again. logic operations not possible in case because need indices , not 0 , 1.

something like:

  • a(~indices)=
  • b(~indices)=

instead of:

indices_2=find(a>=5 | b<=3)  
  • a(indices_2)=
  • b(indices_2)=

and after want split these sets once again.... filtering.

i used indices_2=setdiff(indices, size(a)) did screw computation performance. there other method split matrices subsets without using find twice?

hope understand problem , fits regulations.

i don't understand why can't use find again, nor why can't use logical indexing in case suppose if going restrict accomplish using setdiff:

indices_2 = setdiff(1:numel(a), indices) 

however, if worried performance, should sticking logical indexing:

indices = a<5 & b>3 a(indices)=... b(indices)=... a(~indices)=... b(~indices)=... 

Comments