exm8.m
来自「精通MATLAB GUI设计全书源代码 精通MATLAB GUI的设计全书源代」· M 代码 · 共 46 行
M
46 行
clear
clc
hf=figure('Position',[200 200 600 400] ,...
'Name','Uicontrol1' ,...
'NumberTitle','off');
ha=axes('Position',[0.4 0.1 0.5 0.7],...
'Box','on');
hbSin=uicontrol(hf,...
'Style','pushbutton',...
'Position',[50,140,100,30],...
'String','Plot sin(x)',...
'CallBack',...
['subplot(ha);'...
'x=0:0.1:4*pi;'...
'plot(x,sin(x));'...
'axis([0 4*pi -1 1]);'...
'xlabel(''x'');'...
'ylabel(''y=sin(x)'');'...
'if get(hcGrid,''Value'')==1;'... % add
'grid on;'...
'else;'...
'grid off;'...
'end;'...
]);
hbCos=uicontrol(hf,...
'Style','pushbutton',...
'Position',[50,100,100,30],...
'String','Plot cos(x)',...
'CallBack',...
['subplot(ha);'...
'x=0:0.1:4*pi;'...
'plot(x,cos(x));'...
'axis([0 4*pi -1 1]);'...
'xlabel(''x'');'...
'ylabel(''y=cos(x)'');'...
'if get(hcGrid,''Value'')==1;'... % add
'grid on;'...
'else;'...
'grid off;'...
'end;'...
]);
hbClose=uicontrol(hf,...
'Style','pushbutton',...
'Position',[50,60,100,30],...
'String','Exit',...
'CallBack','close(hf)');
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?