Hello All,
I am currently building up a functionality in a Matlab GUI whereby the user can change the plot displayed on the screen (via a pop-up menu…. this isn't the issue FYI!) and move a vertical line across the plot with the mouse (the x-data is returned from the position of this line). I have no issues creating this mouse-interactive line when the GUI is first generated, but cannot "re-generate" the user-interactive line once the user selects a different dataset from the drop-down menu.
I establish the user-interactive line using the following code in the opening function of the GUI:
handles.yline1 = line([x_start x_start], [y_min,y_max],'ButtonDownFcn',@(hObject,eventdata)postprocessingtry1('startdrag1_Fcn',hObject,eventdata,guidata(hObject)));
Where:
function startdrag1_Fcn(hObject, eventdata, handles) set(handles.figure2,'WindowButtonMotionFcn',@(hObject,eventdata)postprocessingtry1('dragging1_Fcn',hObject,eventdata,guidata(hObject)));
and "dragging1_Fcn" is the function that returns the x-position.
The error occurs once I try to use the same "handles.yline1 = …" declaration within the popupmenu callback function:
Error using handle.handle/set Invalid or deleted object.
Error in postprocessingtry1>dragging1_Fcn (line 341)
set(handles.yline1,'XData',pt.CurrentPoint(1,1)*[1 1]);
Any advice as to how I can regenerate the user-interactive line after selecting and plotting a new dataset (via the pop-up menu) would be IMMENSELY appreciated.
Thank you for your time, Colin Waldo
Best Answer