GUI控件应用Plotting Data to Axes59Word下载.docx
《GUI控件应用Plotting Data to Axes59Word下载.docx》由会员分享,可在线阅读,更多相关《GUI控件应用Plotting Data to Axes59Word下载.docx(4页珍藏版)》请在冰豆网上搜索。
3.
(1)修改两个Axes属性,使用默认值,tag分别为axes1和axes2
(2)修改第一个Pushbutton属性:
(3)类似地,修改第二个Pushbutton属性:
String为PlotAxes2;
Tag为plot2_pushbutton
(4)修改第三个Pushbutton属性:
String为ClearAxes;
Tag为clearAxes_pushbutton
此时,得到:
4.
(1)plot1_pushbutton_Callback.加入以下代码
%selectsaxes1asthecurrentaxes,sothatMatlabknowswheretoplot
%thedata
axes(handles.axes1)
%createsavectorfrom0to10,[0123...10]
x=0:
10;
y=0:
%plotsthexandydata
plot(x,y);
%画的是y=x的图
%addsatitle,x-axisdescription,andy-axisdescription
title('
Axes1'
);
xlabel('
Xdata'
ylabel('
Ydata'
guidata(hObject,handles);
%updatesthehandles
(2)plot2_pushbutton_Callback.加入以下代码
%selectsaxes2asthecurrentaxes,sothatMatlabknowswheretoplot%thedata
axes(handles.axes2)
%createsavector[0149...100]
y=x.^2;
Axes2'
(3)clearPlots_pushbutton_Callback.加入以下代码
%thesetwolinesofcodeclearsbothaxes
cla(handles.axes1,'
reset'
)%cladeletesfromthecurrentaxesall
%graphicsobjectswhosehandlesarenothidden
cla(handles.axes2,'
)
5.保存,并执行
6.如果在functionmyaxes_OpeningFcn(在.m文件中找到该函数),中加入
set(hObject,'
toolbar'
'
figure'
%加在guidata(hObject,handles);
则能在GUI中增加图形操作栏: