?? matlab實用程序百例2.txt
字號:
'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 + -