怎么给Matlab GUI界面设置刷新
1个回答
展开全部
参考
pushbotton1是画图的,pushbutton2是清除的,你要做一个数据传递的工作,因为callback中的变量都是局部变量:
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=0:0.01:pi;
ax1=SUBPLOT(2,1,1);plot(a,sin(a));
ax2=SUBPLOT(2,1,2);plot(a,cos(a));
setappdata(handles.pushbutton1,'ax1',ax1)
setappdata(handles.pushbutton1,'ax2',ax2)
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
ax1=getappdata(handles.pushbutton1,'ax1');
ax2=getappdata(handles.pushbutton1,'ax2');
cla(ax1)
cla(ax2)
pushbotton1是画图的,pushbutton2是清除的,你要做一个数据传递的工作,因为callback中的变量都是局部变量:
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=0:0.01:pi;
ax1=SUBPLOT(2,1,1);plot(a,sin(a));
ax2=SUBPLOT(2,1,2);plot(a,cos(a));
setappdata(handles.pushbutton1,'ax1',ax1)
setappdata(handles.pushbutton1,'ax2',ax2)
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
ax1=getappdata(handles.pushbutton1,'ax1');
ax2=getappdata(handles.pushbutton1,'ax2');
cla(ax1)
cla(ax2)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询