2

I have read couple of posts on how to save brushed data, however, on trying the suggestions on these posts (this, this, this, this and this), 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.

My objectives are:

  1. Brush the data, and

  2. Save the brushed data.

This is what I tried from here but it didn't seem to work:

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);

Can someone show a simple example on how to do this? I am trying to do this in a GUI.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

2 Answers2

1

Adding pause after brush on does the trick:

t=0:0.2:25; plot(t,sin(t),'.-');
brush on
pause
hBrushLine = findall(gca,'tag','Brushing');
brushedData = get(hBrushLine, {'Xdata','Ydata'});
brushedIdx = ~isnan(brushedData{1});
brushedXData = brushedData{1}(brushedIdx);
brushedYData = brushedData{2}(brushedIdx);
0

I actually just answered this this morning.

Check out my answer to this question, and keep my comments in mind to my answer as well, I may have made a mistake in my original solution.

saving user input from uitable matlab GUI?

Hopefully it can help you too!

To summarize, add a waitfor(gcf); output=varToSave (make sure varToSave isn't from a handle/object about to be deleted) where output is the output returned from your GUI function.

Community
  • 1
  • 1
Shaun314
  • 3,191
  • 4
  • 22
  • 27
  • As in, `waitfor(gcf)` pops up a new window. Plus, your answer does not talks about brushing the data. –  Jun 26 '13 at 16:32
  • You said in a GUI, Does your GUI not have a figure?? Also, it sounded like you knew how to to do the "brushing data" part, and the problem was more about trying to do something with that data, which my answer solves. – Shaun314 Jun 26 '13 at 16:35