title: How to correct " Subscript indices must either be real positive integers or logicals." in Matlab in my code?
body: <p>I am very new in Matlab. I made a for loop with i to m ,and j to n. I wrote this code to take a submatrix of a matrix but it keeps giving me this error</p>
  
  <p>Subscript indices must either be real positive integers or logicals.
  this is the code </p>
  
  <pre><code>for i=1:m,
  for j = 1:n,
      display(i);
      display(j);
  
              edgeil = 2;
      edgeib = 2; 
      edgejb = 2; 
      edgejl = 2;
  
  
      if((i-CenteriSE)&lt; 0)
         edgeib = CenteriSE - (-1)*(i-CenteriSE);
  
      end
      if((i+ CenteriSE)&gt; m)
          temp = i+ CenteriSE - m;
          edgeil = CenteriSE - temp;
      end
  
      if((j-CenterjSE)&lt; 0)
          edgejb = CenterjSE- (-1)*(j-CenterjSE);
  
      end
      if((j+ CenterjSE)&gt; n)
          temp2 = j+ CenterjSE - n;
          edgejl = CenterjSE - temp2;
      end
  
      bok1 = round(edgeib);
      bok2 = round(edgeil);
      bok3 = round(edgejb);
      bok4 = round(edgejl);
      display(bok1);
      display(bok2);
      if( (bok1 == round(bok1)) &amp;&amp; (bok2 == round(bok2)) &amp;&amp; (bok3 == round(bok3)) &amp;&amp; (bok4 == round(bok4)))
      B = circles(i-round(bok1):i+round(bok2),j-round(bok3):j+round(bok4));
      end
  </code></pre>
  
  <p>I wrote that if statement and round s to correct it but it doesnt work. Please help me how can I fix this?</p>