title: modify bsxfun for checking significant values
body: <p>I had this problem...i.e. to find significant values between groups in my Data array.
  My solution was:</p>
  
  <pre><code>Data = [1.8,1.4, 1.5;
  60, 70, 80;
  20, 40, 5];
  
  Error = [0.2, 0.1, 0.4;
  20, 30, 10;
  10,5,2];
  
      k = 1; 
  
  for i = 1: size(Data,1)
  
      if ((Data(i,1)-Error(i,1)) &gt; (Data(i,2)+Error(i,2)))
  
        selectedpar(k,1:3) = [i ,1, 2];
  
        k = k+1;
      end
  
      if ((Data(i,1)-Error(i,1)) &gt; (Data(i,3)+Error(i,3)))
  
        selectedpar(k,1:3) = [i , 1, 3];
  
        k = k+1;
      end
  
      if ((Data(i,2)-Error(i,2)) &gt; (Data(i,3)+Error(i,3)))
  
        selectedpar(k,1:3) = [i , 2, 3];
  
        k = k+1;
      end
  
  end
  
  selectedpar = [1    1   2
  3   1   3
  3   2   3]
  </code></pre>
  
  <p>Thanks to an user I came to this other general solution (removed series of if conditions)</p>
  
  <pre><code>DM = Data-Error;
  DP = Data+Error;
  selectedpar = [];
  for k=1:size(Data,1)
     [I,J]=find(tril(bsxfun(@gt, DM(k,:), DP(k,:).')));
     selectedpar = [selectedpar ; k+zeros(size(I)), J, I];  %#ok&lt;AGROW&gt;
  end
  </code></pre>
  
  <p>Now I would like to add another condition: in particular instead of the single if I would like to check for</p>
  
  <pre><code>if ((Data(i,1)-Error(i,1)) &gt; (Data(i,2)+Error(i,2)) || (Data(i,1)+Error(i,1)) &lt; (Data(i,2)-Error(i,2))) etc...
  </code></pre>
  
  <p>so my ugly solution would be</p>
  
  <pre><code>    k = 1; 
  
  for i = 1: size(Data,1)
  
      if ((Data(i,1)-Error(i,1)) &gt; (Data(i,2)+Error(i,2)) || (Data(i,1)+Error(i,1)) &lt; (Data(i,2)-Error(i,2)) )
  
        selectedpar(k,1:3) = [i ,1, 2];
  
        k = k+1;
      end
  
      if ((Data(i,1)-Error(i,1)) &gt; (Data(i,3)+Error(i,3)) || (Data(i,1)+Error(i,1)) &lt; (Data(i,3)-Error(i,3)))
  
        selectedpar(k,1:3) = [i , 1, 3];
  
        k = k+1;
      end
  
      if ((Data(i,2)-Error(i,2)) &gt; (Data(i,3)+Error(i,3)) || (Data(i,2)+Error(i,2)) &lt; (Data(i,3)-Error(i,3)))
  
        selectedpar(k,1:3) = [i , 2, 3];
  
        k = k+1;
      end
  
  end
  
  selectedpar = [1    1   2
  3   1   2
  3   1   3
  3   2   3]
  </code></pre>
  
  <p>(correct solution)</p>
  
  <p>How can I modify the bsxfun to add the second part of the new if condition (the one after the OR)</p>
  
  <p>thanks </p>