matlab实用程序(五)

1. 浏览流体数据

h0=figure('toolbar','none',...
    'position',[198 56 450 468],...
    'name','实例61');
h1=axes('parent',h0,...
    'position',[0.3 0.45 0.5 0.5],...
    'visible','off');
[x,y,z,v]=flow;
xmin=min(x(:));
ymin=min(y(:));
zmin=min(z(:));
xmax=max(x(:));
ymax=max(y(:));
zmax=max(z(:));
u1=uimenu('parent',h0,...
    'tag','u1',...
    'label','绘图',...
    'background',[0.75 0.75 0.75]);
u11=uimenu('parent',u1,...
    'tag','u11',...
    'label','绕X轴旋转-45度',...
    'background',[0.75 0.75 0.75],...
    'callback',[...
        'cla,',...
        'hslice=surf(linspace(xmin,xmax,100),linspace(ymin,ymax,100),zeros(100));,',...
        'rotate(hslice,[-1,0,0],-45),',...
        'xd=get(hslice,''xdata'');,',...
        'yd=get(hslice,''ydata'');,',...
        'zd=get(hslice,''zdata'');']);
u12=uimenu('parent',u1,...
    'tag','u12',...
    'label','绕Y轴旋转-45度',...
    'background',[0.75 0.75 0.75],...
    'callback',[...
        'cla,',...
        'hslice=surf(linspace(xmin,xmax,100),linspace(ymin,ymax,100),zeros(100));,',...
        'rotate(hslice,[0,-1,0],-45),',...
        'xd=get(hslice,''xdata'');,',...
        'yd=get(hslice,''ydata'');,',...
        'zd=get(hslice,''zdata'');']);
b1=uicontrol('parent',h0,...
    'style','pushbutton',...
    'units','points',...
    'tag','b1',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'string','设置颜色',...
    'position',[50 120 60 25],...
    'callback',[...
        'delete(hslice),',...
        'h=slice(x,y,z,v,xd,yd,zd);,',...
        'set(h,''facecolor'',''interp'',''edgecolor'',''none'',''diffusestrength'',0.8)']);
b2=uicontrol('parent',h0,...
    'style','pushbutton',...
    'units','points',...
    'tag','b2',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'string','添加切片1',...
    'position',[240 120 60 25],...
    'callback',[...
        'hold on,',...
        'hx=slice(x,y,z,v,xmax,[],[]);,',...
        'set(hx,''facecolor'',''interp'',''edgecolor'',''none'')']);
b3=uicontrol('parent',h0,...
    'style','pushbutton',...
    'units','points',...
    'tag','b3',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'string','添加切片2',...
    'position',[240 70 60 20],...
    'callback',[...
        'hold on,',...
        'hy=slice(x,y,z,v,ymax,[],[]);,',...
        'set(hy,''facecolor'',''interp'',''edgecolor'',''none'')']);
b4=uicontrol('parent',h0,...
    'style','pushbutton',...
    'units','points',...
    'tag','b4',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'string','添加切片3',...
    'position',[240 20 60 20],...
    'callback',[...
        'hold on,',...
        'hz=slice(x,y,z,v,zmax-1,[],[]);,',...
        'set(hz,''facecolor'',''interp'',''edgecolor'',''none'')']);
b5=uicontrol('parent',h0,...
    'style','pushbutton',...
    'units','points',...
    'tag','b5',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'string','灯光效果',...
    'position',[50 70 60 20],...
    'callback',[...
        'daspect([1 1 1]),',...
        'axis tight,',...
        'box on,',...
        'view(-38.5,16),',...
        'camzoom(1.4),',...
        'camproj perspective,',...
        'lightangle(-45,45)']);
b6=uicontrol('parent',h0,...
    'style','pushbutton',...
    'units','points',...
    'tag','b6',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'string','colorbar',...
    'position',[50 20 60 20],...
    'callback','colorbar(''horiz'')');
b7=uicontrol('parent',h0,...
    'style','pushbutton',...
    'units','points',...
    'tag','b7',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'string','关闭',...
    'fontsize',14,...
    'position',[145 75 60 20],...
    'callback','close');


2. 简单计算器:

h0=figure('toolbar','none',...
    'position',[200 60 220 240],...
    'name','实例62');
b0=uicontrol('parent',h0,...
    'units','points',...
    'tag','b0',...
    'style','pushbutton',...
    'string','0',...
    'fontsize',12,...
    'position',[5 15 35 20],...
    'backgroundcolor',[0.75 0.75 0.75],...
    'callback',[...
        'if k==''0''&i==0,',...
        'errordlg(''数字首位不能为0''),',...
        'else,',...
        'k=[k,''0''];,',...
        'if k==''00'',',...
        'k=''0'';,',...
        'end,',...
        'set(e1,''string'',k);,',...
        'end']);
b15=uicontrol('parent',h0,...
    'units','points',...
    'tag','b15',...
    'style','pushbutton',...
    'string','=',...
    'fontsize',12,...
    'position',[45 15 35 20],...
    'backgroundcolor',[0.75 0.75 0.75],...
    '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;

3. 字母统计

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');

4. 图形的几何操作:

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',...
    'tag','e3',...
    'style','edit',...
    'horizontal','right',...
    'backgroundcolor',[1 1 1],...
    'fontsize',12,...
    'position',[140 80 30 20],...
    'string',num2str(now(3)));
t3=uicontrol('parent',h0,...
    'units','points',...
    'tag','t3',...
    'style','text',...
    'string','日',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'fontsize',14,...
    'position',[175 80 20 20]);
e4=uicontrol('parent',h0,...
    'units','points',...
    'tag','e4',...
    'style','edit',...
    'backgroundcolor',[1 1 1],...
    'horizontal','right',...
    'fontsize',12,...
    'position',[20 30 100 20],...
    'string',[num2str(now(4)),':',num2str(now(5)),':',num2str(now(6))]);
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'string','关闭',...
    'fontsize',12,...
    'position',[150 30 50 20],...
    'callback',[...
        'k=1;,',...
        'close']);
k=0;
while find(get(0,'children'))==h0
    now1=fix(clock)
    set(e1,'string',num2str(now1(1)));
    set(e2,'string',num2str(now1(2)));
    set(e3,'string',num2str(now1(3)));
    set(e4,'string',[num2str(now1(4)),':',num2str(now1(5)),':',num2str(now1(6))]);
    pause(1)
    if k==1
        break
    end
end

5. 时间计算器:

h0=figure('toolbar','none',...
    'position',[200 150 300 250],...
    'name','实例65');
huidiao=[...
        'k=0;,',...
        'fyear=str2num(get(e1,''string''));,',...
        'fmonth=str2num(get(e2,''string''));,',...
        'fday=str2num(get(e3,''string''));,',...
        'syear=str2num(get(e4,''string''));,',...
        'smonth=str2num(get(e5,''string''));,',...
        'sday=str2num(get(e6,''string''));,',...
        'month=[0 31 28 31 30 31 30 31 31 30 31 30 31];,',...
        'k=fix(fyear/4);,',...
        'if rem(fyear,4)==0,',...
        'month(3)=29;,',...
        'else,',...
        'k=k+1;,',...
        'month(3)=28;,',...
        'end,',...
        'sum=0;,',...
        'for i=1:fmonth,',...
        'sum=sum+month(i);,',...
        'end,',...
        'fdday=fyear*365+sum+fday+k;,',...
        'l=fix(syear/4);,',...
        'if rem(syear,4)==0,',...
        'month(3)=29;,',...
        'else,',...
        'l=l+1;,',...
        'month(3)=28;,',...
        'end,',...
        'ssum=0;,',...
        'for i=1:smonth,',...
        'ssum=ssum+month(i);,',...
        'end,',...
        'sdday=syear*365+ssum+sday+l;,',...
        'dday=abs(fdday-sdday);,',...
        'set(e7,''string'',[num2str(dday),''天'']);'];
t0=uicontrol('parent',h0,...
    'units','points',...
    'tag','t0',...
    'style','text',...
    'string','开始日期:',...
    'horizontalalignment','right',...
    'fontsize',15,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[10 160 80 20]);
t8=uicontrol('parent',h0,...
    'units','points',...
    'tag','t8',...
    'style','text',...
    'string','结束日期:',...
    'horizontalalignment','right',...
    'fontsize',15,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[115 160 80 20]);
e1=uicontrol('parent',h0,...
    'units','points',...
    'tag','e1',...
    'style','edit',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[20 130 50 20]);
t1=uicontrol('parent',h0,...
    'units','points',...
    'tag','t1',...
    'style','text',...
    'string','年',...
    'horizontalalignment','left',...
    'fontsize',15,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[75 130 20 20]);
e2=uicontrol('parent',h0,...
    'units','points',...
    'tag','e2',...
    'style','edit',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[20 100 50 20]);
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','月',...
    'horizontalalignment','left',...
    'fontsize',15,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[75 100 20 20]);
e3=uicontrol('parent',h0,...
    'units','points',...
    'tag','e3',...
    'style','edit',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[20 70 50 20]);
t3=uicontrol('parent',h0,...
    'units','points',...
    'tag','t3',...
    'style','text',...
    'string','日',...
    'horizontalalignment','left',...
    'fontsize',15,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[75 70 20 20]);
e4=uicontrol('parent',h0,...
    'units','points',...
    'tag','e4',...
    'style','edit',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[120 130 50 20]);
t4=uicontrol('parent',h0,...
    'units','points',...
    'tag','t4',...
    'style','text',...
    'string','年',...
    'horizontalalignment','left',...
    'fontsize',15,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[175 130 20 20]);
e5=uicontrol('parent',h0,...
    'units','points',...
    'tag','e5',...
    'style','edit',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[120 100 50 20]);
t5=uicontrol('parent',h0,...
    'units','points',...
    'tag','t5',...
    'style','text',...
    'string','月',...
    'horizontalalignment','left',...
    'fontsize',15,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[175 100 20 20]);
e6=uicontrol('parent',h0,...
    'units','points',...
    'tag','e6',...
    'style','edit',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[120 70 50 20]);
t6=uicontrol('parent',h0,...
    'units','points',...
    'tag','t6',...
    'style','text',...
    'string','日',...
    'horizontalalignment','left',...
    'fontsize',15,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[175 70 20 20]);
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'string','计算日期',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[20 40 50 20],...
    'callback',huidiao);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'style','pushbutton',...
    'string','关闭',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[20 10 50 20],...
    'callback','close');
e7=uicontrol('parent',h0,...
    'units','points',...
    'tag','e7',...
    'style','edit',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[120 10 80 20]);
t7=uicontrol('parent',h0,...
    'units','points',...
    'tag','t7',...
    'style','text',...
    'string','两个日期相差:',...
    'horizontalalignment','right',...
    'fontsize',15,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[100 30 110 20]);

6. 数字操作

h0=figure('toolbar','none',...
    'position',[200 150 350 200],...
    'name','实例66');
e1=uicontrol('parent',h0,...
    'units','points',...
    'tag','e1',...
    'style','edit',...
    'backgroundcolor',[1 1 1],...
    'position',[20 90 80 20],...
    'fontsize',12,...
    'horizontalalignment','right');
e2=uicontrol('parent',h0,...
    'units','points',...
    'tag','e2',...
    'style','edit',...
    'backgroundcolor',[1 1 1],...
    'position',[160 90 80 20],...
    'fontsize',12,...
    'horizontalalignment','right');
t1=uicontrol('parent',h0,...
    'units','points',...
    'tag','t1',...
    'style','text',...
    'string','初始数值(十进制):',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[15 110 90 20],...
    'fontsize',12,...
    'horizontalalignment','left');
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','转换结果:',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[155 110 90 20],...
    'fontsize',12,...
    'horizontalalignment','left');
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'string','二进制',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[30 50 50 20],...
    'callback',[...
        'k=get(e1,''string'');,',...
        'k2=str2num(k);,',...
        'bk=dec2bin(k2);,',...
        'set(e2,''string'',num2str(bk));']);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'style','pushbutton',...
    'string','清除',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[170 50 50 20],...
    'callback',[...
        'set(e1,''string'','''');,',...
        'set(e2,''string'','''');']);
b3=uicontrol('parent',h0,...
    'units','points',...
    'tag','b3',...
    'style','pushbutton',...
    'string','十六进制',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[30 15 50 20],...
    'callback',[...
        'k=get(e1,''string'');,',...
        'k3=str2num(k);,',...
        'hk=dec2hex(k3);,',...
        'set(e2,''string'',num2str(hk));']);
b4=uicontrol('parent',h0,...
    'units','points',...
    'tag','b4',...
    'style','pushbutton',...
    'string','关闭',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[170 15 50 20],...
    'callback','close'); 


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
matlab实用程序百例-matlab实用程序百例.rar 此压缩包包含了很大的实例程序 对于大家学习Matlab的提高是很有帮助的 提高自己的编程能力也是很有帮助的 例如: 1-32是:图形应用篇 33-66是:界面设计篇 67-84是:图形处理篇 85-100是:数值分析篇 实例1:三角函数曲线(1) function shili01 h0=figure('toolbar','none',...     'position',[198 56 350 300],...     'name','实例01'); h1=axes('parent',h0,...    'visible','off'); x=-pi:0.05:pi; y=sin; plot; xlabel; ylabel; title函数曲线'); grid on 实例2:三角函数曲线(2) function shili02 h0=figure('toolbar','none',...     'position',[200 150 450 350],...     'name','实例02'); x=-pi:0.05:pi; y=sin cos; plot; grid on xlabel; ylabel; title; 实例3:图形的叠加 function shili03 h0=figure('toolbar','none',...     'position',[200 150 450 350],...     'name','实例03'); x=-pi:0.05:pi; y1=sin; y2=cos; plot(x,y1,...     '-*r',...     x,y2,...     '--og'); grid on xlabel; ylabel; title; 实例4:双y轴图形的绘制 function shili04 h0=figure('toolbar','none',...     'position',[200 150 450 250],...     'name','实例04'); x=0:900;a=1000;b=0.005; y1=2*x; y2=cos; [haxes,hline1,hline2]=plotyy; axes) ylabel; axes) ylabel; 实例5:单个轴窗口显示多个图形 function shili05 h0=figure('toolbar','none',...     'position',[200 150 450 250],...     'name','实例05'); t=0:pi/10:2*pi; [x,y]=meshgrid; subplot plot,cos) axis equal subplot z=sin-cos; plot axis subplot h=sin cos; plot axis subplot g=.^2)-.^2); plot axis 更多,参考附件!
matlab实用程序100例 目录 1 1-32是:图形应用篇 4 三角函数曲线 4 实例1:三角函数曲线(1) 4 实例2:三角函数曲线(2) 4 实例4:双y轴图形的绘制 5 实例5:单个轴窗口显示多个图形 5 实例7:条形图形 6 实例8:区域图形 7 实例9:饼图的绘制 8 实例10:阶梯图 8 实例11:枝干图 9 实例12:罗盘图 9 实例13:轮廓图 10 实例14:交互式图形 10 实例14:交互式图形 11 实例15:变换的傅立叶函数曲线 12 实例16:劳伦兹非线形方程的无序活动 12 实例17:填充图 13 实例18:条形图和阶梯形图 13 实例19:三维曲线图 14 实例20:图形的隐藏属性 15 实例21PEAKS函数曲线 15 实例22:片状图 16 实例23:视角的调整 16 实例24:向量场的绘制 17 实例25:灯光定位 18 实例26:柱状图 19 实例27:设置照明方式 20 实例28:羽状图 21 立体透视程序 21 实例29:立体透视(1) 21 实例30:立体透视(2) 22 实例31:表面图形 23 33-66是:界面设计篇 25 实例33:曲线转换按钮 25 实例34:栅格控制按钮 26 实例35:编辑框的使用 27 实例36:弹出式菜单 28 实例37:滑标的使用 29 实例38:多选菜单 29 实例39:菜单控制的使用 30 实例40:UIMENU菜单的应用 31 实例41:除法计算器 32 实例43:添加环境效果 34 实例44:改变坐标轴范围 37 实例45:简单运算器 39 实例46:曲线色彩的修改 40 实例47:曲线标记 42 实例48:修改曲型 43 实例49:指定坐标轴范围 45 用户界面 46 实例50:绘制不同函数曲线的用户界面 46 实例51:可设置函数曲线图视角的用户界面 48 实例52:可设置函数曲线图视角的用户界面 50 实例53:可设置函数曲线光源的用户界面 52 实例54:添加效果 53 实例55:查询日期 54 图形效果 57 实例56:图形效果(1) 57 实例57:图形效果(2) 60 实例58:可控制小球运动速度的用户界面 63 实例59:设置坐标轴纵横轴比 65 实例61:浏览流体数据 69 实例62:简单计算器 72 实例63:字母统计 80 实例64:图形的几何操作 82 实例65:时间计算器 84 实例66:数字操作 88 实例67-84是:图形处理篇 90 67:图像的块操作 90 实例68:图形的过滤操作 92 实例69:图像的频率操作 93 实例70:函数变换 94 实例71:RADON函数变换 96 图像分析 98 实例72:图像分析(1) 98 实例78:图像分析(2) 100 实例73:过滤图像 102 实例74:图像的区域处理 103 实例75:图像的颜色处置 105 实例76:交换显示图像 107 实例77:矢量数据的显示 108 实例79:图像逻辑操作 109 实例80:进度条的使用 111 例81:MRI数据的显示 112 实例82:图像类型转换 114 实例83:特殊的图像显示技术 115 实例84:图像的几何操作 117 85-100是:数值分析篇 118 常见的插值程序 118 实例85:拉个朗日插值 118 实例86:三次样条插值法 120 实例87:NEWTON插值 123 实例88:hermite插值 125 实例89:mewton形式的hermite插值 127 实例90:平方根法 130 实例91:gauss消去法 131 实例92:三角分解法 133 常见的迭代法 134 实例93:jacobi迭代法 134 实例94:gauss迭代法 136 实例95:sor迭代法 138 实例96:mewton迭代法 140 实例97:broyden迭代法 141 实例98:逆broyden迭代法 143 实例99:最速下降法 146 实例100:共额梯度法 148
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值