title: How to solve && operands to logical scalar
body: <p>After I run the code in matlab, I encounter this error and unsure how to solve it. How can I solve this problem.</p>
  <blockquote>
  <p>Warning:</p>
  <p>Operands to the || and &amp;&amp; operators must be convertible to logical scalar values.</p>
  </blockquote>
  <pre><code>    Jgray = double(rgb2gray(J));
      % Calculate the Gradients
      [dIx, dIy] = gradient(Jgray);
      if max(dIx)&lt;=103 &amp;&amp; max(dIy)&lt;=100
          B =  abs(dIy) - abs(dIx);
      else
          B = abs(dIx) - abs(dIy);
      end
  </code></pre>