title: How to plot a real time signal in MATLAB?
body: <p>I'm building a smile detection system, and I need to plot the probability of smile (from video input) like the graphs on the right in <a href="https://www.youtube.com/watch?v=v-53aku3axo" rel="nofollow">this video</a>.</p>
  
  <p>How can I do this in MATLAB?</p>
  
  <h2>Notes</h2>
  
  <p>I'm currently displaying the video frames with OpenCV &amp; IntraFace default code, which looks something like this :</p>
  
  <pre><code>cf = 0; % Current Frame.
  % create a figure to draw upon
  S.fh = figure('units','pixels',...
                'position',[100 150 frame_w frame_h],...
                'menubar','none',...
                'name','Smile Detector',...              
                'numbertitle','off',...
                'resize','off',...
                'renderer','painters');
  
  % create axes
  S.ax = axes('units','pixels',...  
              'position',[1 1 frame_w frame_h],...
              'drawmode','fast');
  
  set(S.fh,'KeyPressFcn',@pb_kpf);          
  
  S.im_h = imshow(zeros(frame_h,frame_w,3,'uint8'));
  hold on;
  S.frame_h = text(50,frame_h-50,['Frame ' int2str(cf)] , 'fontsize', 15, 'Color' , 'c');
  
  while true &amp;&amp; ~stop_pressed
    tic;
    im = cap.read;  
    cf = cf + 1;        
    if isempty(im), 
      warning('EOF'); 
      break ;
    end
  
    set(S.im_h,'cdata',im); % update frame
    set(S.frame_h , 'string' ,['Frame ' int2str(cf)]);  
    do_something_with_frame(im);
  
    if isempty(output.pred) % if lost/no face, delete all drawings      
      if drawed, delete_handlers(); end
    else % face found       
      update_GUI(); 
    end
  drawnow;
  end
  
  close;
  
  end
  </code></pre>
  
  <p>And I want to add a live / moving graph like in the video. The graph will display a single value (a probability) between 0 and 1. And it should be updated with every new frame, therefore the plot should "flow" as the video flows.</p>
  
  <h2>What Have I Tried</h2>
  
  <p>I tried creating a new figure just like <code>S</code> in the code. But I cannot plot into it. I am also ok with adding the live graph in the same figure (<code>S.fh</code>), preferrably under the scene.</p>