title: Matlab GUI using GUIDE : Want to dynamically update graphs
body: <p>I've written a Matlab script that reads in data using a virtual COMM port in <strong>real-time</strong>. I've done a significant amount of signal processing in an mfile.</p>
  
  <p>Next, I felt the need to have a compact GUI that displays the information as summary. </p>
  
  <p>I only recently started digging and reading more of Matlab's built-in GUI tool, GUIDE. I've followed a few tutorials and am successfully able to get my graphs to display on my GUI <strong>after a button-press</strong>.</p>
  
  <p>However, I want the <strong>GUI to update in real-time</strong>. My data vector is constantly updating (reading in data from the COMM port). I want the GUI to keep <strong>updating the graphs</strong> with the newer data, as opposed to relying on a button press for an update. Can someone please point me in the right direction for background updating?</p>
  
  <p>Here is the relevant code currently for the GUI:</p>
  
  <pre><code>% --- Executes on button press in pushbutton1.
  function pushbutton1_Callback(hObject, eventdata, handles)
  % hObject    handle to pushbutton1 (see GCBO)
  % eventdata  reserved - to be defined in a future version of MATLAB
  % handles    structure with handles and user data (see GUIDATA)
  global data
  global time
  
  % Time domain plot
  axes(handles.timeDomainPlot);
  cla;
  plot (time, data);
  </code></pre>
  
  <p>EDIT Changed code:</p>
  
  <pre><code>% --- Executes on button press in pushbutton1.
  function pushbutton1_Callback(hObject, eventdata, handles)
  % hObject    handle to pushbutton1 (see GCBO)
  % eventdata  reserved - to be defined in a future version of MATLAB
  % handles    structure with handles and user data (see GUIDATA)
  
  %Setting it to display something when it ends
  % t = timer('TimerFcn', 'timerOn=false; disp(''Updating GUI!'')',... 
  t = timer(... 
              'TasksToExecute', 10, ... % Number of times to run the timer object
              'Period', 3, ...                
              'TimerFcn', GUIUpdate()); 
  
  %Starting the timer
  start(t)
  
  function GUIUpdate()
  global data
  global time
  %Parameters below axes
      global min
      global max 
        % Time domain plot
      axes(handles.timeDomainPlot);
      cla;
      plot (time, data);
      %Other parameters:
      set(handles.mean, 'String', mean);
      set(handles.max, 'String', max);
  </code></pre>
  
  <p>The error that I get is:</p>
  
  <pre><code>??? Error using ==&gt; GUI_Learning&gt;GUIUpdate
  Too many output arguments.
  
  Error in ==&gt;
  @(hObject,eventdata)GUI_Learning('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
  
  
  ??? Error while evaluating uicontrol Callback
  </code></pre>