Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


palmar
Posts:
48
Registered:
11/16/07


pushbutton saving problem
Posted:
May 15, 2014 7:03 AM


Hi there
I have a 2d plot (hhh handle) done with imagesc to which I want to add a line if a pushbutton is pressed, and remove the same lien if the push button is released.
When the pushbutton is pressed the line shows OK, however if the pushbutton is released there is this error:
Undefined function or variable 'Hline'
Lokks line the program can´t remember the Hline value even it is being updated with guidata. What am I doing wrong? Thanks
Here is the function
function abc(x) % x is a m x n matrix hhh=imagesc(x)
% now a pushbutton to put or remove a line in the above plot
uicontrol('Style','radiobutton','String','put_remove_line',... 'units','normalized','pos', [tf_left 0 .1/2 1/25],'parent',hhh,'HandleVisibility','on', 'fontSize',6,'Callback',{@put_remove_line ,delta_f_line, hhh ,Hline});
end % end abc function %radiobutton callback function
function put_remove_line(hObject,event,delta_f_line,hhh,Hline) a=get(hObject,'Value'); if a % if button is pressed a axes(hhh) xlimits=get(gca,'XLim'); Hline.xxx=line(xlimits,[delta_f_line], 'LineStyle',':','LineWidth',2); else delete(Hline.xxx,) end guidata(hObject,Hline) end



