⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matlab实用程序百例2.txt

📁 Community中的程序,由Tom Irvine编制的。它的使用方法:在Matlab Command Window中输入 >>zoomfft 将显示出要求输入...我是新手,请教个问题:
💻 TXT
📖 第 1 页 / 共 5 页
字号:
    'callback',[...
        'k=get(e1,''string'');,',...
        'if g==''+'',',...
        'm=m+str2num(k);,',...
        'end,',...
        'if g==''-'',',...
        'm=m-str2num(k);,',...
        'end,',...
        'if g==''*'',',...
        'm=m*str2num(k);,',...
        'end,',...
        'if g==''/'',',...
        'if k==''0'',',...
        'errordlg(''除数不能为0'');,',...
        'end,',...
        'm=m/str2num(k);,',...
        'end,',...
        'set(e1,''string'',num2str(m));,',...
        'i=0;']);
b11=uicontrol('parent',h0,...
    'units','points',...
    'tag','b11',...
    'style','pushbutton',...
    'string','+',...
    'fontsize',12,...
    'position',[85 15 35 20],...
    'backgroundcolor',[0.75 0.75 0.75],...
    'callback',[...
        'i=i+1;,',...
        'if i==1,',...
        'm=str2num(k);,',...
        'set(e1,''string'',''0'');,',...
        'end,',...
        'if i>1,',...
        'k=get(e1,''string'');,',...
        'if g==''+'',',...
        'm=m+str2num(k);,',...
        'end,',...
        'if g==''-'',',...
        'm=m-str2num(k);,',...
        'end,',...
        'if g==''*'',',...
        'm=m*str2num(k);,',...
        'end,',...
        'if g==''/'',',...
        'if k==''0'',',...
        'errordlg(''除数不能为0'');,',...
        'end,',...
        'm=m/str2num(k);,',...
        'end,',...
        'set(e1,''string'',num2str(m));,',...
        'i=1;,',...
        'end,',...
        'k=''0'';,',...
        'g=''+'';']);
b16=uicontrol('parent',h0,...
    'units','points',...
    'tag','b16',...
    'style','pushbutton',...
    'string','关闭',...
    'fontsize',12,...
    'position',[125 15 35 20],...
    'backgroundcolor',[0.75 0.75 0.75],...
    'callback','close');
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'string','1',...
    'fontsize',12,...
    'position',[5 45 35 20],...
    'backgroundcolor',[0.75 0.75 0.75],...
    'callback',[...
        'if k==''0'',',...
        'k='''';,',...
        'end,',...
        'k=[k,''1''];,',... 
        'set(e1,''string'',k);']);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'style','pushbutton',...
    'string','2',...
    'fontsize',12,...
    'position',[45 45 35 20],...
    'backgroundcolor',[0.75 0.75 0.75],...
    'callback',[...
        'if k==''0'',',...
        'k='''';,',...
        'end,',...
        'k=[k,''2''];,',... 
        'set(e1,''string'',k);']);
b3=uicontrol('parent',h0,...
    'units','points',...
    'tag','b3',...
    'style','pushbutton',...
    'string','3',...
    'fontsize',12,...
    'position',[85 45 35 20],...
    'backgroundcolor',[0.75 0.75 0.75],...
    'callback',[...
        'if k==''0'',',...
        'k='''';,',...
        'end,',...
        'k=[k,''3''];,',... 
        'set(e1,''string'',k);']);
b14=uicontrol('parent',h0,...
    'units','points',...
    'tag','b14',...
    'style','pushbutton',...
    'string','/',...
    'fontsize',12,...
    'position',[125 45 35 20],...
    'backgroundcolor',[0.75 0.75 0.75],...
    'callback',[...
        'i=i+1;,',...
        'if i==1,',...
        'm=str2num(k);,',...
        'set(e1,''string'',''0'');,',...
        'end,',...
        'if i>1,',...
        'k=get(e1,''string'');,',...
        'if k==''0'',',...
        'errordlg(''除数不能为0'');,',...
        'end,',...
        'if ~(k==''0''),',...
        'if g==''+'',',...
        'm=m+str2num(k);,',...
        'end,',...
        'if g==''-'',',...
        'm=m-str2num(k);,',...
        'end,',...
        'if g==''*'',',...
        'm=m*str2num(k);,',...
        'end,',...
        'if g==''/'',',...
        'm=m/str2num(k);,',...
        'end,',...
        'set(e1,''string'',num2str(m));,',...
        'end,',...
        'i=1;,',...
        'end,',...
        'k=''0'';,',...
        'g=''/'';']);
b4=uicontrol('parent',h0,...
    'units','points',...
    'tag','b4',...
    'style','pushbutton',...
    'string','4',...
    'fontsize',12,...
    'position',[5 75 35 20],...
    'backgroundcolor',[0.75 0.75 0.75],...
    'callback',[...
        'if k==''0'',',...
        'k='''';,',...
        'end,',...
        'k=[k,''4''];,',... 
        'set(e1,''string'',k);']);
b5=uicontrol('parent',h0,...
    'units','points',...
    'tag','b5',...
    'style','pushbutton',...
    'string','5',...
    'fontsize',12,...
    'position',[45 75 35 20],...
    'backgroundcolor',[0.75 0.75 0.75],...
    'callback',[...
        'if k==''0'',',...
        'k='''';,',...
        'end,',...
        'k=[k,''5''];,',... 
        'set(e1,''string'',k);']);
b6=uicontrol('parent',h0,...
    'units','points',...
    'tag','b6',...
    'style','pushbutton',...
    'string','6',...
    'fontsize',12,...
    'position',[85 75 35 20],...
    'backgroundcolor',[0.75 0.75 0.75],...
    'callback',[...
        'if k==''0'',',...
        'k='''';,',...
        'end,',...
        'k=[k,''6''];,',... 
        'set(e1,''string'',k);']);
b13=uicontrol('parent',h0,...
    'units','points',...
    'tag','b13',...
    'style','pushbutton',...
    'string','*',...
    'fontsize',12,...
    'position',[125 75 35 20],...
    'backgroundcolor',[0.75 0.75 0.75],...
    'callback',[...
        'i=i+1;,',...
        'if i==1,',...
        'm=str2num(k);,',...
        'set(e1,''string'',''0'');,',...
        'end,',...
        'if i>1,',...
        'k=get(e1,''string'');,',...
        'if g==''+'',',...
        'm=m+str2num(k);,',...
        'end,',...
        'if g==''-'',',...
        'm=m-str2num(k);,',...
        'end,',...
        'if g==''*'',',...
        'm=m*str2num(k);,',...
        'end,',...
        'if g==''/'',',...
        'if k==''0'',',...
        'errordlg(''除数不能为0'');,',...
        'end,',...
        'm=m/str2num(k);,',...
        'end,',...
        'set(e1,''string'',num2str(m));,',...
        'i=1;,',...
        'end,',...
        'k=''0'';,',...
        'g=''*'';']);
b7=uicontrol('parent',h0,...
    'units','points',...
    'tag','b7',...
    'style','pushbutton',...
    'string','7',...
    'fontsize',12,...
    'position',[5 105 35 20],...
   'backgroundcolor',[0.75 0.75 0.75],...
    'callback',[...
        'if k==''0'',',...
        'k='''';,',...
        'end,',...
        'k=[k,''7''];,',... 
        'set(e1,''string'',k);']);
b8=uicontrol('parent',h0,...
    'units','points',...
    'tag','b8',...
    'style','pushbutton',...
    'string','8',...
    'fontsize',12,...
    'position',[45 105 35 20],...
    'backgroundcolor',[0.75 0.75 0.75],...
    'callback',[...
        'if k==''0'',',...
        'k='''';,',...
        'end,',...
        'k=[k,''8''];,',... 
        'set(e1,''string'',k);']);
b9=uicontrol('parent',h0,...
    'units','points',...
    'tag','b9',...
    'style','pushbutton',...
    'string','9',...
    'fontsize',12,...
    'position',[85 105 35 20],...
    'backgroundcolor',[0.75 0.75 0.75],...
    'callback',[...
        'if k==''0'',',...
        'k='''';,',...
        'end,',...
        'k=[k,''9''];,',... 
        'set(e1,''string'',k);']);
b12=uicontrol('parent',h0,...
    'units','points',...
    'tag','b12',...
    'style','pushbutton',...
    'string','-',...
    'fontsize',12,...
    'position',[125 105 35 20],...
    'backgroundcolor',[0.75 0.75 0.75],...
    'callback',[...
        'i=i+1;,',...
        'if i==1,',...
        'm=str2num(k);,',...
        'set(e1,''string'',''0'');,',...
        'end,',...
        'if i>1,',...
        'k=get(e1,''string'');,',...
        'if g==''+'',',...
        'm=m+str2num(k);,',...
        'end,',...
        'if g==''-'',',...
        'm=m-str2num(k);,',...
        'end,',...
        'if g==''*'',',...
        'm=m*str2num(k);,',...
        'end,',...
        'if g==''/'',',...
        'if k==''0'',',...
        'errordlg(''除数不能为0'');,',...
        'end,',...
        'm=m/str2num(k);,',...
        'end,',...
        'set(e1,''string'',num2str(m));,',...
        'i=1;,',...
        'end,',...
        'k=''0'';,',...
        'g=''-'';']);
e1=uicontrol('parent',h0,...
    'units','points',...
    'tag','e1',...
    'style','edit',...
    'horizontalalignment','right',...
    'fontsize',12,...
    'string','0',...
    'position',[45 135 115 20],...
    'backgroundcolor',[1 1 1]);
k=get(e1,'string');
i=0;
m=0;
实例63:字母统计

h0=figure('toolbar','none',...
    'position',[200 150 350 200],...
    'name','实例63');
choose=1;
e1=uicontrol('parent',h0,...
    'units','points',...
    'tag','e1',...
    'style','edit',...
    'backgroundcolor',[1 1 1],...
    'min',0,...
    'max',2,...
    'fontsize',12,...
    'horizontalalignment','left',...
    'position',[20 20 120 100]);
t1=uicontrol('parent',h0,...
    'units','points',...
    'tag','t1',...
    'style','text',...
    'string','请输入字母(大小写皆可):',...
    'fontsize',10,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[20 125 120 15]);
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'string','开始统计',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[180 100 60 20],...
    'callback',[...
        's=get(e1,''string'');,',...
        'n=length(s);,',...
        'jb=0;,',...
        'jl=0;,',...
        'for i=1:n,',...
        'if (abs(s(i))>64)&(abs(s(i))<91),',...
        'jb=jb+1;,',...
        'end,',...
        'if (abs(s(i))>96)&(abs(s(i))<123),',...
        'jl=jl+1;,',...
        'end,',...
        'end,',...
        'j=jb+jl;,',...
        'if choose==1,',...
        'msgbox([''共有字母'',num2str(j),''个!'',''其中大写字母'',num2str(jb),''个!''],''统计结果''),',...
        'end,',...
        'if choose==2,',...
        'msgbox([''共有字母'',num2str(j),''个!'',''其中小写字母'',num2str(jl),''个!''],''统计结果'');,',...
        'end']);
u1=uimenu('parent',h0,...
    'label','字母分类',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'tag','u1');
u11=uimenu('parent',u1,...
    'label','大写字母',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'tag','u11',...
    'checked','on',...
    'callback',[...
        'set(u11,''checked'',''on'');,',...
        'set(u12,''checked'',''off'');,',...
        'choose=1;']);
u12=uimenu('parent',u1,...
    'label','小写字母',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'tag','u12',...
     'callback',[...
        'set(u12,''checked'',''on'');,',...
        'set(u11,''checked'',''off'');,',...
        'choose=2;']);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'style','pushbutton',...
    'string','清除',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[180 60 60 20],...
    'callback','set(e1,''string'','''')');
b3=uicontrol('parent',h0,...
    'units','points',...
    'tag','b3',...
    'style','pushbutton',...
    'string','关闭',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[180 20 60 20],...
    'callback','close');
实例64:图形的几何操作

h0=figure('toolbar','none',...
    'position',[200 150 300 150],...
    'name','实例64');
now=fix(clock);
e1=uicontrol('parent',h0,...
    'units','points',...
    'tag','e1',...
    'style','edit',...
    'backgroundcolor',[1 1 1],...
    'horizontal','right',...
    'fontsize',12,...
    'position',[20 80 30 20],...
    'string',num2str(now(1)));
t1=uicontrol('parent',h0,...
    'units','points',...
    'tag','t1',...
    'style','text',...
    'string','年',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'fontsize',14,...
    'position',[55 80 20 20]);
e2=uicontrol('parent',h0,...
    'units','points',...
    'tag','e2',...
    'style','edit',...
    'backgroundcolor',[1 1 1],...
    'horizontal','right',...
    'fontsize',12,...
    'position',[80 80 30 20],...
    'string',num2str(now(2)));
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','月',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'fontsize',14,...
    'position',[115 80 20 20]);
e3=uicontrol('parent',h0,...
    'units','points',...

⌨️ 快捷键说明

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