I have five 3-D arrays and I would like to find any elements that are common to 2 or more of the arrays and that are non-zero. I've tried doing something like:
mask = (dat1==dat2) | (dat1 == dat3) | (dat1 == dat4) | (dat1 == dat5) | (dat2 == dat3) | (dat2 == dat4) | (dat2 == dat5) | (dat3 == dat4) | (dat3 == dat5) | (dat4 == dat5);
but since zeros are common, I get an array of nearly all 1's. I'm trying to avoid just using a 'for' loop to step through all the non-zero elements and checking. There should only be about 50 or so common non-zero elements out of nearly 100,000 total elements.
Thank you for your time helping me.
EDIT: What I want to know is the location of the elements and I don't really care what the value is (as long as it isn't zero).
Best Answer