我有2-30个图,我想通过GUI(指南)中的复选标记选择来控制可见性。但我无法让它发挥作用。请帮忙。
这里我的代码有两个简单的图:
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
X1=[1 2 3 4]
Y1=[-1 -2 -3 -4]
X2=[1 2 3 4]
Y2=[1 2 3 4]
handles.handle_plot1 = plot(X1,Y1);
handles.handle_plot2 = plot(X2,Y2);
guidata(hObject, handles);
% --- Executes on button press in checkbox1.
function checkbox1_Callback(hObject, eventdata, handles)
handles.handle_plot1 = handles.handle_plot1
if (get(hObject,'Value')) == 1
set(handle_plot1, 'visible' , 'on')
else
set(handle_plot1, 'visible' , 'off')
end
% --- Executes on button press in checkbox2.
function checkbox2_Callback(hObject, eventdata, handles)
handles.handle_plot2 = handles.handle_plot2
if (get(hObject,'Value')) == 1
set(handle_plot2, 'visible' , 'on')
else
set(handle_plot2, 'visible' , 'off')
end
但是我收到了这个错误:
Undefined function or variable 'handle_plot1'.
Error in test>checkbox1_Callback (line 91)
set(handle_plot1, 'visible' , 'on')
我做错了什么?