title: MATLAB update waitbar
body: <p>I am trying to implement a "percent complete" bar in a MATLAB program, using the waitbar function. However, I am having trouble with it. Here is the code that I have currently:</p>
  
  <hr>
  
  <p>in my GUI</p>
  
  <pre><code>POSITION = [53.3333 20 188.5446 20];   
  H = uiwaitbar(POSITION); 
  for percentageDone = 0;
     uiwaitbar(H,percentageDone);
  end 
  </code></pre>
  
  <hr>
  
  <p>then</p>
  
  <pre><code>function h = uiwaitbar(varargin)
  
  if ishandle(varargin{1}) 
      ax = varargin{1}; 
      value = varargin{2}; 
      p = get(ax,'Child'); 
      x(3:4) = value; 
      set(p,'XData',x) 
      return 
  end 
  
  pos = varargin{1}; 
  bg_color = [1 1 1]; 
  fg_color = [0 .5 0]; 
  h = axes('Units','pixels',... 
      'Position',pos,... 
      'XLim',[0 100],'YLim',[0 1],... 
      'XTick',[],'YTick',[],... 
      'Color',bg_color,... 
      'XColor',bg_color,'YColor',bg_color); 
  patch([0 0 0 0],[0 1 1 0],fg_color,... 
      'Parent',h,... 
      'EdgeColor','none',... 
      'EraseMode','none'); 
  
  end
  </code></pre>
  
  <p>Elsewhere in the script, I have a KeyPressFcn callback, in which the user inputs the answer to their questions. At the end of this callback, for every correct answer I want the waitbar to fill up a little. However, no matter what values I assign to percentageDone variable the waitbar in the GUI does not change at all.</p>
  
  <p>Can anybody help me with this?</p>