guide (代码:1\gui_biancheng.m)
% 打开窗体钱先执行该函数
function gui_biancheng_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
handles.x=-pi:0.01:pi; %全局变量
guidata(hObject, handles);
sin按钮
function sin_Callback(hObject, eventdata, handles)
x=handles.x;
y=sin(x);
plot(handles.plotaa,x,y); %在坐标轴(plotaa)中画线
cos按钮
function cos_Callback(hObject, eventdata, handles)
x=handles.x;
y=cos(x);
plot(handles.plotaa,x,y); %在坐标轴(plotaa)中画线
clear按钮
function clear_Callback(hObject, eventdata, handles)
try
delete(allchild(handles.plotaa)); %清空坐标轴,删除坐标轴的所有孩子结点
end