I am still a uncertain if this is what you want, but here goes:
idx0 = (dat1==dat2 | dat1==dat3 | dat1==dat4 | dat1==dat5) & logical(dat1);
idx1 = (dat1==dat2 | dat2==dat3 | dat2==dat4 | dat2==dat5) & logical(dat2);
idx2 = (dat1==dat3 | dat2==dat3 | dat3==dat4 | dat3==dat5) & logical(dat3);
idx3 = (dat1==dat4 | dat2==dat4 | dat3==dat4 | dat4==dat5) & logical(dat4);
idx4 = (dat1==dat5 | dat2==dat5 | dat3==dat5 | dat4==dat5) & logical(dat5);
IDX = idx0 | idx1 | idx2 | idx3 | idx4
Now IDX has a 1 where two or more arrays share a non-zero value...
Best Answer