Domanda

How to find index of common elements in two cells?

Thanks.

for example:

cell1= {
        A
        B
        C
        D 
        E
        f
         }

cell2= {
        g
        h
        f
        D
        i
        l 
        m
        n
         }

return index of D and f in cell2 for example have 3 and 4 index.

  ans= 
       0
       0
       0
       4
       0
       3
È stato utile?

Soluzione

You can use the second output argument of ismember for that purpose:

[~, index] = ismember(cell1, cell2);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top