title: why does the code stuck in the while loop even though i try to break on the loop?(matlab)
body: <p><strong>The code</strong></p>
  
  <pre><code>ite = 5 ;
  cell = 5;
  MRJIT = xlsread('5 Node.xlsm',1,'L62: P67');
  max_col = 5 ;
  
  for m=1:ite
      for n=1:max_col 
         a = randi(cell)
         b = randi(cell)
          while (eq(a,b) ||(MRJIT(a,n)==0 &amp;&amp; MRJIT(b,n)==0)) 
              if (a~=b)&amp;&amp;(MRJIT(a,n)&gt; 0 || MRJIT(b,n)&gt;0)
                  break;
              end
              a = randi(cell)
              b = randi(cell)
  
          end
          MRJIT([a,n b,n]) = MRJIT([b,n a,n]) %swap value
      end
  end
  </code></pre>
  
  <p><strong>Code explanation</strong></p>
  
  <p>there are 5 column on this table, <a href="https://i.stack.imgur.com/Gdym6.jpg" rel="nofollow noreferrer">5 node.xls</a>
  the point of this code is to swap values between 2 cell on each column from the table above that are selected by choosing 2 random number that is <strong>a</strong> and <strong>b</strong> but only if one of the selected cell value is not zero, if both of the cell values equal to zero, it will need to select another 2 random number until the one of the selected cells values is not equal to zero</p>
  
  <p><strong>The Question</strong></p>
  
  <p>1.why does the code stuck in the while loop? when i try to force stop the program, it shows some of the a and b values are not the same or equal to zero, but it kept stuck on the while loop</p>
  
  <ol start="2">
  <li>Why does the program only run on column 1 and not the others? </li>
  </ol>