Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Stop interrupt button & delete line from graph error at GUI

1 view
Skip to first unread message

Eric

unread,
Dec 30, 2011, 9:42:07 PM12/30/11
to
Hi. The link below is the snapshot of my GUI.

<http://www.imgplace.com/viewimg440/3707/63383235.png>

The error appears when I pressed "Stop" or "Reset" to stop the yellow needle from moving at the graph. Below is the error message from the MATLAB command windows:
??? Error using ==> delete
Invalid handle object.

Error in ==> placeT at 164
delete(PPIline)

Now I suspect the error comes from "Generate" button, "Stop" button, or "placeT" callfunction. Below are the snippet of my codes for the 3 functions above:

This is the "Generate Target" button

function genTarget_Callback(hObject, eventdata, handles)
% initialize the flag variable
set(handles.genTarget, 'UserData', 0);

% While the flag variable is zero, the loop continues
while( get( handles.genTarget, 'UserData' ) == 0 )

circlev2(handles.realTarget,handles.range); % print target on real target
placeT( ...);
handles.btndown = 0;
placeT( ...);
drawnow
end

This is the "Stop" button

function simStop_Callback(hObject, eventdata, handles)
% toogle the flag variable to stop other processes.
set( handles.genTarget, 'UserData', 1);
guidata( hObject, handles );

This is the placeT function

function placeT( display, h, tgMx, range , btndown, emp, NoMx)
.....
PPIline = plot(h.radarDisplay, X, Y, 'Color', 'y' );
....
pause(0.01);
delete(PPIline)

I have tried the interrupt method, in which when the Stop button is press, the "handles.genTarget" is set to "1" and it will cause the yellow needle stop moving, but it did not work.

Was it due to my interrupt method is wrong?
Or I have used the wrong way to delete the line?

Any advice is much appreciated. Thanks and Happy New Year.

ImageAnalyst

unread,
Jan 1, 2012, 11:31:20 AM1/1/12
to
For some reason PPline is not in scope. Find out where you set it
with the plot() command and then step through line by line to see
where it disappears. Is it possible that in the placeT() function you
have an if get(handles.genTarget, 'UserData') block where it will call
either plot() or delete() depending on the value of UserData? If so
then when it goes to delete PPline, PPline does not exist yet for that
running of placeT(). So you might want to either make PPline
persistent (see the help) or use findobj() to find all line objects on
your axes and clear them like this:

%===============================================
% Clear lines from the current graphics axes, gca.
function ClearLinesFromAxes()
axesHandlesToChildObjects = findobj(gca, 'Type', 'line');
if ~isempty(axesHandlesToChildObjects)
delete(axesHandlesToChildObjects);
end
return; % from ClearLinesFromAxes
0 new messages