exm11.m

来自「精通MATLAB GUI设计全书源代码 精通MATLAB GUI的设计全书源代」· M 代码 · 共 48 行

M
48
字号
clear
clc
hf=figure('Position',[200 200 600 400] ,...
           'Name','Uicontrol1' ,...
           'NumberTitle','off');
 hp=uipanel('units','pixels',...                          %面板
            'Position',[48 78 110 90],...
       'Title','Panel','FontSize',12);                    %面板标题
ha=axes('Position',[0.4 0.1 0.5 0.7],...
            'Box','on');
hbg=uibuttongroup('units','pixels',...                 %按钮组
                'Position',[48 178 104 70],...
               'Title','Button Group' );                   %按钮组标题
hbSin=uicontrol(hf,...
                'Style','pushbutton',...                    %sin按钮
                'Position',[50,120,100,30],...
                'String','Plot sin(x)',...
                'CallBack',...
                            ['subplot(ha);'...
                             'x=0:0.1:4*pi;'...
                             'plot(x,sin(x));'...            %绘制sin
                             'axis([0 4*pi -1 1]);'...
                             'grid on;'...
                            'xlabel(''x'');'...
                            'ylabel(''y=sin(x)'');'...
                             ]);  
hbClose=uicontrol(hf,...
                'Style','pushbutton',...                    %结束按钮
                'Position',[50,80,100,30],...
                'String','Exit',...
                'CallBack','close(hf)'); 
hrboxoff=uicontrol(gcf,'Style','radio',...             %单选按钮off
               'Position',[50 180 100 20],...
               'String','Set box off',...
               'Value',0,...
               'CallBack',[...
                              'set(hrboxon,''Value'',0);'...
                              'set(hrboxoff,''Value'',1);'...
                              'set(gca,''Box'',''off'');']);
hrboxon=uicontrol(gcf,'Style','radio',...              %单选按钮on
                'Position',[50 210 100 20],...
                'String','Set box on',...
                'Value',1,...
                'CallBack',[...
                               'set(hrboxon,''Value'',1);'...
                              'set(hrboxoff,''Value'',0);'...
                              'set(gca,''Box'',''on'');']); 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?