【发布时间】:2014-05-15 11:07:34
【问题描述】:
我有一个使用 imagesc 完成的 2d 绘图(hhh 句柄),如果按下单选按钮,我想在其中添加一条线,如果释放按钮,则删除相同的留置权。
当按钮被按下时,该行显示 OK,但是如果按钮被释放,则会出现以下错误:
未定义的函数或变量'Hline'
程序无法记住 Hline 值,即使它正在使用 guidata 进行更新。我究竟做错了什么?谢谢
这里是函数
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
【问题讨论】:
标签: matlab matlab-guide uicontrol