title: MATLAB Updating a global variable from one function does not get reflected in the other function
body: <p>I have a function that uses a global variable and I want to change its value from another function. Even though I tried in many ways, the function that uses the value seems not getting updated with the new value of the global variable. Here's the code I'm using.</p>
  
  <p><strong>calculate.m</strong></p>
  
  <pre><code>function calculateTest()
  
  global isStop;
  global value;
  
  value=0;
  while ~isStop
      pause(1);
      value = value+1
  end
  
  end
  </code></pre>
  
  <p><strong>start.m</strong></p>
  
  <pre><code>function start()
  
  global isStop;
  isStop = 0;
  calculateTest();
  end
  </code></pre>
  
  <p><strong>stop.m</strong></p>
  
  <pre><code>function stop()
  
  global isStop;
  isStop = 1;
  end
  </code></pre>
  
  <p>When I call start() the value starts getting printed. But even if I call stop(), it never stops. It keeps on printing. Do you have any idea of what I am missing?</p>
  
  <p>(I have tried <em>while isStop==0</em> as well. But the result was the same.</p>