title: How to brush the plot and then save the brushed data in GUI?
body: <p>I have read couple of posts on how to save brushed data, however, on trying the suggestions on these posts (<a href="http://undocumentedmatlab.com/blog/accessing-plot-brushed-data/" rel="nofollow">this</a>, <a href="http://www.mathworks.com/matlabcentral/answers/25597" rel="nofollow">this</a>, <a href="http://www.mathworks.com/matlabcentral/answers/25488-brush-data-can-not-be-obtained" rel="nofollow">this</a>, <a href="http://www.mathworks.com/matlabcentral/answers/5539-way-to-get-handle-to-just-brushed-object" rel="nofollow">this</a> and <a href="http://www.mathworks.com/help/matlab/ref/brush.html" rel="nofollow">this</a>), none of them seem to be working. One of the problem I encountered while trying these suggestions is that the program runs all the way through the end before any data is brushed, and therefore, the saved data is an empty matrix.</p>
  
  <p>My objectives are:</p>
  
  <ol>
  <li><p>Brush the data, and </p></li>
  <li><p>Save the brushed data.</p></li>
  </ol>
  
  <p>This is what I tried <a href="http://undocumentedmatlab.com/blog/accessing-plot-brushed-data/" rel="nofollow">from here</a> but it didn't seem to work:</p>
  
  <pre><code>t=0:0.2:25; plot(t,sin(t),'.-');
  brush on
  hBrushLine = findall(gca,'tag','Brushing');
  brushedData = get(hBrushLine, {'Xdata','Ydata'});
  brushedIdx = ~isnan(brushedData{1});
  brushedXData = brushedData{1}(brushedIdx);
  brushedYData = brushedData{2}(brushedIdx);
  </code></pre>
  
  <p>Can someone show a simple example on how to do this? I am trying to do this in a GUI.</p>