Create a callback that waits for the brush to include some data and then display them
Show older comments
I have the following simple example:
x=-4:0.1:4;
y= x.^2-1;
f=figure;
h=plot( x, y );
bO = brush(gcf);
set(bO,'enable','on');
data=logical(get(h,'brushdata'));
disp(data)
If I run it all the data will be zero. If I run it until the set command, choose subsequently the data from the plot and then continue with executing the other two commands the selected data will be displayed.
How can I control with the callback to wait until I gather the data and then display them?
Accepted Answer
More Answers (2)
Giorgos Papakonstantinou
on 19 Jun 2013
0 votes
2 Comments
Jan
on 19 Jun 2013
Please do not bump your question after a short period of time. The contributors of this forum answer, when they find the time and know a solution. If the question is bumped to the top without really new informations, reading it another time wastes the time of the voluntary helpers.
Please use the answer section for answers only. Comments about the question are better inside the comment section of the question. Thanks.
Giorgos Papakonstantinou
on 19 Jun 2013
Andrew Fairgrieve
on 1 Oct 2021
Its not a pretty solution but it seems to work:
b=brush;
b.Enable = 'on';
waitfor(b,'Enable','off')
This will cause the script to wait for the user to turn off the brush, before continuing with the rest of the script. If the user has used the brush to delete points,
~isnan(PlotHandle.YData)
, can then be used to identify data the user has deleted and then this can be applied to related data in the script.
Categories
Find more on App Building in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!