Linkdata + Brush Not Responding

I want to delete data points from a plot using brush and remove. I want these points to be deleted from my workspace variables. I can't get it to work when I have any pause or waitfor commands afterwards. It works fine when nothing follows. This is part of my code:
>fig=plot(X,Y);
brush on
linkdata on
waitfor(fig)
fig2=plot(X,Y)

 Respuesta aceptada

Walter Roberson
Walter Roberson el 6 de Jun. de 2012

0 votos

What is your intention by using waitfor() ? waitfor() waits for the given object to be deleted.
If your intention is to give an opportunity for the user to do the brushing, then you would usually just return from the function at that point, having already established some control (e.g., 'Done' pushbutton) for the user to signal readiness to continue on.

7 comentarios

Adam
Adam el 6 de Jun. de 2012
Yes. I just want to give the user an opportunity to do brushing.
Adam
Adam el 6 de Jun. de 2012
Is there anyway to do this without creating several functions? I just want 1 m file
Walter Roberson
Walter Roberson el 6 de Jun. de 2012
Recursion and a state-machine. But I do NOT recommend that approach, not for this purpose.
Just put your several functions into your one .m file.
Adam
Adam el 6 de Jun. de 2012
I've never done this multiple function technique. I'm a new programmer. I'm thinking something like this, but it's only making matters worse:
function [X,Y,Area,SR]=UPDAreaFinder()
%lines of code
figP=plot(X,Y);
linkdata on
brush on
figP=uicontrol('String','Done', 'Callback', {@part2function}');
function Areatotal=part2function(X,Y,Area,SR)
%lines of code
Walter Roberson
Walter Roberson el 6 de Jun. de 2012
Possibly
function UPDAreaFinder(X, Y, Area, SR)
%lines of code
plot(X,Y);
linkdata on
brush on
uicontrol('String','Done', 'Callback', {@part2function, X, Y, Area, SR}');
function part2function(src, evt, X, Y, Area, SR)
%lines of code
Notice I did not return the Areatotal -- you cannot return values from these kinds of callbacks.
See though
http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.3F
Adam
Adam el 7 de Jun. de 2012
It's almost there. Thanks. The only problem is X,Y are not being passed in the updated form from the brushing and deleting.
Adam
Adam el 7 de Jun. de 2012
It all works now. Thanks. I used assignin in the first function for X and Y and evalin in the second function for X and Y.
I don't understand why it's not sending the right X and Y with the callback.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.

Preguntada:

el 6 de Jun. de 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by