www.gusucode.com > MATLAB的100个例子 包括界面设计,图像处理等源码程序 > matlab实用程序百例2.txt

    实例47:曲线标记

h0=figure('toolbar','none',...
    'position',[198 56 408 468],...
    'name','my second gui');
h1=axes('parent',h0,...
    'position',[0.15 0.45 0.7 0.5],...
    'visible','on');
x=0:0.1:2*pi;
k=plot(x,sin(x),'*');
xlabel('自变量X');
ylabel('函数值Y');
title('标记类型的改变');
p1=uicontrol('parent',h0,...
    'style','pushbutton',...
    'string','+',...
    'fontsize',20,...
    'foregroundcolor',[1 1 1],...
    'backgroundcolor',[0 0 0],...
    'position',[60 100 50 20],...
    'callback','set(k,''marker'',''+'')');
p2=uicontrol('parent',h0,...
    'style','pushbutton',...
    'string','o',...
    'fontsize',20,...
    'foregroundcolor',[1 1 1],...
    'backgroundcolor',[0 0 0],...
    'position',[170 100 50 20],...
    'callback','set(k,''marker'',''o'')');
p3=uicontrol('parent',h0,...
    'style','pushbutton',...
    'string','x',...
    'fontsize',20,...
    'foregroundcolor',[1 1 1],...
    'backgroundcolor',[0 0 0],...
    'position',[280 100 50 20],...
    'callback','set(k,''marker'',''x'')');
p4=uicontrol('parent',h0,...
    'style','pushbutton',...
    'backgroundcolor',[1 1 1],...
    'fontsize',20,...
    'fontweight','demi',...
    'string','关闭',...
    'position',[150 30 80 60],...
    'callback','close');
t1=uicontrol('parent',h0,...
    'style','text',...
    'string','星号',...
    'fontsize',12,...
    'fontweight','demi',...
    'position',[60 120 50 20]);
t2=uicontrol('parent',h0,...
    'style','text',...
    'string','圆圈',...
    'fontsize',12,...
    'fontweight','demi',...
    'position',[170 120 50 20]);
t3=uicontrol('parent',h0,...
    'style','text',...
    'string','叉号',...
    'fontsize',12,...
    'fontweight','demi',...
    'position',[280 120 50 20]);
实例48:修改曲型

h0=figure('toolbar','none',...
    'position',[198 56 408 468],...
    'name','实例48');
h1=axes('parent',h0,...
    'position',[0.15 0.45 0.7 0.5],...
    'visible','on');
x=0:0.1:2*pi;
k=plot(x,sin(x));
xlabel('自变量X');
ylabel('函数值Y');
title('线型的改变');
p1=uicontrol('parent',h0,...
    'style','pushbutton',...
    'string','-.',...
    'fontsize',20,...
    'foregroundcolor',[1 1 1],...
    'backgroundcolor',[0 0 0],...
    'position',[60 100 50 20],...
    'callback','set(k,''linestyle'',''-.'')');
p2=uicontrol('parent',h0,...
    'style','pushbutton',...
    'string',':',...
    'fontsize',20,...
    'foregroundcolor',[1 1 1],...
    'backgroundcolor',[0 0 0],...
    'position',[170 100 50 20],...
    'callback','set(k,''linestyle'','':'')');
p3=uicontrol('parent',h0,...
    'style','pushbutton',...
    'string','-',...
    'fontsize',20,...
    'foregroundcolor',[1 1 1],...
    'backgroundcolor',[0 0 0],...
    'position',[280 100 50 20],...
    'callback','set(k,''linestyle'',''-'')');
p4=uicontrol('parent',h0,...
    'style','pushbutton',...
    'backgroundcolor',[1 1 1],...
    'fontsize',20,...
    'fontweight','demi',...
    'string','关闭',...
    'position',[150 30 80 60],...
    'callback','close');
t1=uicontrol('parent',h0,...
    'style','text',...
    'string','点划线',...
    'fontsize',12,...
    'fontweight','demi',...
    'position',[60 120 50 20]);
t2=uicontrol('parent',h0,...
    'style','text',...
    'string','虚线',...
    'fontsize',12,...
    'fontweight','demi',...
    'position',[170 120 50 20]);
t3=uicontrol('parent',h0,...
    'style','text',...
    'string','实线',...
    'fontsize',12,...
    'fontweight','demi',...
    'position',[280 120 50 20]);
实例49:指定坐标轴范围

h0=figure('toolbar','none',...
    'position',[198 56 408 468],...
    'name','实例49');
h1=axes('parent',h0,...
    'position',[0.15 0.45 0.7 0.5],...
    'visible','on');
x=0:0.1:2*pi;
y=sin(x);
plot(x,y);
xlabel('X');
ylabel('Y');
title('坐标轴范围的改变');
h=get(gca,'xlim');
k=get(gca,'ylim');
e1=uicontrol('parent',h0,...
    'style','edit',...
    'string',eval(num2str(h(1))),...
    'horizontalalignment','right',...
    'position',[80 120 100 20]);
t1=uicontrol('parent',h0,...
    'style','text',...
    'string','X轴最小值',...
    'position',[100 145 80 20]);
e2=uicontrol('parent',h0,...
    'style','edit',...
    'string',eval(num2str(h(2))),...
    'horizontalalignment','right',...
    'position',[80 60 100 20]);
t2=uicontrol('parent',h0,...
    'style','text',...
    'string','X轴最大值',...
    'position',[100 85 80 20]);
e3=uicontrol('parent',h0,...
    'style','edit',...
    'string',eval(num2str(k(1))),...
    'horizontalalignment','right',...
    'position',[250 120 100 20]);
t3=uicontrol('parent',h0,...
    'style','text',...
    'string','Y轴最小值',...
    'position',[270 145 80 20]);
e4=uicontrol('parent',h0,...
    'style','edit',...
    'string',eval(num2str(k(2))),...
    'horizontalalignment','right',...
    'position',[250 60 100 20]);
t4=uicontrol('parent',h0,...
    'style','text',...
    'string','X轴最小值',...
    'position',[270 85 80 20]);
p1=uicontrol('parent',h0,...
    'style','pushbutton',...
    'string','设置',...
    'position',[105 10 50 30],...
    'callback',[...
        'a=str2num(get(e1,''string''));,',...
        'b=str2num(get(e2,''string''));,',...
        'c=str2num(get(e3,''string''));,',...
        'd=str2num(get(e4,''string''));,',...
        'axis([a b c d]),',...
        'drawnow']);
p2=uicontrol('parent',h0,...
    'style','pushbutton',...
    'string','关闭',...
    'position',[275 10 50 30],...
    'callback','close');
实例50:绘制不同函数曲线的用户界面

h0=figure('toolbar','none',...
    'position',[198 56 408 468],...
    'name','实例50');
h1=axes('parent',h0,...
    'position',[0.29 0.45 0.7 0.5],...
    'visible','on');
f=uicontrol('parent',h0,...
    'style','frame',...
    'position',[5 50 90 400]);
p1=uicontrol('parent',h0,...
    'style','pushbutton',...
    'position',[150 100 60 40],...
    'string','绘图',...
    'callback',[...
        'm=str2num(get(e1,''string''));,',...
        'n=str2num(get(e2,''string''));,',...
        'a=get(l1,''value'');,',...
        'x=m:0.1:n;',...
        'if a==1,',...
        'plot(x,sin(x)),',...
        'end,',...
        'if a==2,',...
        'plot(x,cos(x)),',...
        'end,',...
        'if a==3,',...
        'plot(x,exp(x)),',...
        'end']);
p2=uicontrol('parent',h0,...
    'style','pushbutton',...
    'position',[270 100 60 40],...
    'string','关闭',...
    'callback','close');
l1=uicontrol('parent',h0,...
    'style','listbox',...
    'position',[10 300 80 80],...
    'string','sin(x)|cos(x)|exp(x)',...
    'value',1,...
    'max',0.5,...
    'min',0);
f2=uicontrol('parent',h0,...
    'style','text',...
    'string','选择函数',...
    'fontsize',10,...
    'position',[10 380 80 20]);
r1=uicontrol('style','radio',...
    'string','grid on',...
    'value',0,...
    'position',[10 100 60 20],...
    'callback',[...
        'grid on,',...
        'set(r1,''value'',1);,',...
        'set(r2,''value'',0)']);
r2=uicontrol('style','radio',...
    'string','grid off',...
    'position',[10 80 60 20],...
    'value',1,...
    'callback',[...
        'grid off,',...
        'set(r2,''value'',1);,',...
        'set(r1,''value'',0)']);
e1=uicontrol('parent',h0,...
    'style','edit',...
    'string',0,...
    'position',[20 210 60 20],...
    'horizontalalignment','right');
e2=uicontrol('parent',h0,...
    'style','edit',...
    'string','3',...
    'position',[20 150 60 20],...
    'horizontalalignment','right');
t1=uicontrol('parent',h0,...
    'style','text',...
    'string','X from',...
    'fontsize',10,...
    'position',[20 230 60 20],...
    'horizontalalignment','center');
t2=uicontrol('parent',h0,...
    'style','text',...
    'string','To',...
    'fontsize',10,...
    'position',[20 170 60 20],...
    'horizontalalignment','center');
实例51:可设置函数曲线图视角的用户界面

h0=figure('toolbar','none',...
    'position',[198 56 408 468],...
    'name','实例51');
h1=axes('parent',h0,...
    'position',[0.15 0.45 0.7 0.5],...
    'visible','off');
[x,y]=meshgrid(-8:0.5:8);
r=sqrt(x.^2+y.^2)+eps;
z=sin(r)./r;
f1=surf(x,y,z);
shading interp
view(-50,30)
camlight left
colormap([1 0 0])
fv=get(h0,'colormap');
ifv=fv;
p1=uicontrol('parent',h0,...
    'style','pushbutton',...
    'string','重置',...
    'position',[280 120 50 30],...
    'callback',[...
        'set(s1,''value'',ifv(1));,',...
        'set(s2,''value'',ifv(2));,',...
        'set(s3,''value'',ifv(3));,',...
        'set(h0,''colormap'',ifv)']);
p2=uicontrol('parent',h0,...
    'style','pushbutton',...
    'string','关闭',...
    'position',[280 60 50 30],...
    'callback','close');
s1=uicontrol('parent',h0,...
    'style','slider',...
    'min',0,...
    'max',1,...
    'value',fv(1),...
    'position',[20 150 200 20],...
    'callback',[...
        's1k=get(s1,''value'');,',...
        'fv(1)=s1k;,',...
        'set(h0,''colormap'',fv);']);
t1=uicontrol('parent',h0,...
    'style','text',...
    'string','改变红色成分',...
    'position',[20 170 100 20]);
s2=uicontrol('parent',h0,...
    'style','slider',...
    'min',0,...
    'max',1,...
    'value',fv(2),...
    'position',[20 100 200 20],...
    'callback',[...
        's2k=get(s2,''value'');,',...
        'fv(2)=s2k;,',...
        'set(h0,''colormap'',fv);']);
t2=uicontrol('parent',h0,...
    'style','text',...
    'string','改变绿色成分',...
    'position',[20 120 100 20]);
s3=uicontrol('parent',h0,...
    'style','slider',...
    'min',0,...
    'max',1,...
    'value',fv(3),...
    'position',[20 50 200 20],...
    'callback',[...
        's3k=get(s3,''value'');,',...
        'fv(3)=s3k;,',...
        'set(h0,''colormap'',fv);']);
t1=uicontrol('parent',h0,...
    'style','text',...
    'string','改变蓝色成分',...
    'position',[20 70 100 20]); 
实例52:可设置函数曲线图视角的用户界面

h0=figure('toolbar','none',...
    'position',[198 56 408 468],...
    'name','实例52');
h1=axes('parent',h0,...
    'position',[0.15 0.5 0.7 0.5],...
    'visible','off');
[x,y]=meshgrid(-8:0.5:8);
r=sqrt(x.^2+y.^2)+eps;
z=sin(r)./r;
fh=surf(x,y,z);
shading interp
view([-60 30])
fv=get(h1,'view');
fv2=fv;
camlight left
sh1=uicontrol('parent',h0,...
    'style','slider',...
    'max',1,...
    'min',-1,...
    'value',fv(1)/180,...
    'position',[20 150 200 20],...
    'callback',[...
        'fv(1)=90*get(sh1,''value'');,',...
        'set(h1,''view'',[fv(1) fv(2)]),',...
        'set(ed1,''string'',fv(1))']);   
text1=uicontrol('parent',h0,...
    'style','text',...
    'string','方位角的变化滑标',...
    'position',[20 170 200 20]);
sh2=uicontrol('parent',h0,...
    'style','slider',...
    'max',1,...
    'min',-1,...
    'value',fv(2)/180,...
    'position',[20 90 200 20],...
    'callback',[...
        'fv(2)=90*get(sh2,''value'');,',...
        'set(h1,''view'',[fv(1) fv(2)]),',...
        'set(ed2,''string'',fv(2))']);
text2=uicontrol('parent',h0,...
    'style','text',...
    'string','仰角的变化滑标',...
    'position',[20 110 200 20]);
ed1=uicontrol('parent',h0,...
    'style','edit',...
    'string',fv(1),...
    'position',[30 30 50 20]);
text3=uicontrol('parent',h0,...
    'style','text',...
    'string','方位角的数值',...
    'position',[20 50 80 20]);
ed2=uicontrol('parent',h0,...
    'style','edit',...
    'string',fv(2),...
    'position',[150 30 50 20]);
text4=uicontrol('parent',h0,...
    'style','text',...
    'string','仰角的数值',...
    'position',[135 50 80 20]);
pf1=uicontrol('parent',h0,...
    'style','pushbutton',...
    'string','重置',...
    'position',[280 120 50 30],...
    'callback',[...
        'set(h1,''view'',fv2),',...
        'set(sh1,''value'',fv2(1)/180),',...
        'set(sh2,''value'',fv2(2)/180),',...
        'set(ed1,''string'',fv2(1)),',...
        'set(ed2,''string'',fv2(2))']);
pf2=uicontrol('parent',h0,...
    'style','pushbutton',...
    'string','关闭',...
    'position',[280 60 50 30],...
    'callback','close'); 
实例53:可设置函数曲线光源的用户界面

h0=figure('toolbar','none',...
    'position',[198 56 408 468],...
    'name','实例53');
h1=axes('parent',h0,...
    'position',[0.15 0.5 0.7 0.5],...
    'visible','off');
[x,y]=meshgrid(-8:0.5:8);
r=sqrt(x.^2+y.^2)+eps;
z=sin(r)./r;
fh=surf(x,y,z);
shading interp
view([-60 30])
camlight left
lightk=light('position',[0 -2 1]);
button1=uicontrol('parent',h0,...
    'style','pushbutton',...
    'string','设置光线',...
    'position',[80 60 70 30],...
    'callback',[...
        'an1=inputdlg(''光线来源的X轴坐标'');,',...
        'k1=str2num(an1{1});,',...
        'an2=inputdlg(''光线来源的Y轴坐标'');,',...
        'k2=str2num(an2{1});,',...
        'an3=inputdlg(''光线来源的Z轴坐标'');,',...
        'k3=str2num(an3{1});,',...
        'set(lightk,''position'',[k1 k2 k3]);,',...
        'set(edit1,''string'',[''['',num2str(k1),'' '',num2str(k2),'' '',num2str(k3),'']'']);']);
button2=uicontrol('parent',h0,...
    'style','pushbutton',...
    'string','关闭',...
    'position',[250 60 70 30],...
    'callback','close');
edit1=uicontrol('parent',h0,...
    'style','edit',...
    'max',2,...
    'min',0,...
    'fontsize',15,...
    'backgroundcolor',[1 1 1],...
    'string','[0 -2 1]',...
    'position',[80 110 220 30]);
text1=uicontrol('parent',h0,...
    'style','text',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'fontsize',15,...
    'string','光线来源坐标',...
    'position',[80 140 220 30]);
实例54:添加效果

h0=figure('toolbar','none',...
    'position',[200 50 300 350],...
    'name','实例54');
h1=axes('parent',h0,...
    'position',[0.2 0.4 0.6 0.6],...
    'visible','off');
ezsurf('sin(sqrt(x.^2+y.^2))/sqrt(x.^2+y.^2)',[-6*pi,6*pi])
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'string','设置',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[40 50 50 20],...
    'callback',[...
        'view(0,75);,',...
        'shading interp;,',...
        'lightangle(-45,30);,',...
        'k=findobj(gca,''type'',''surface'');,'...
        'set(k,''facelighting'',''phong'');,',...
        'set(k,''ambientstrength'',0.3);,',...
        'set(k,''diffusestrength'',0.8);,',...
        'set(k,''specularstrength'',0.9);,',...
        'set(k,''specularexponent'',25);,',...
        'set(k,''backfacelighting'',''unlit'')']);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'style','pushbutton',...
    'string','关闭',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[120 50 50 20],...
    'callback','close');
实例55:查询日期

h0=figure('toolbar','none',...
    'position',[198 56 408 468],...
    'name','实例55');
h1=axes('parent',h0,...
    'position',[0.15 0.5 0.7 0.5],...
    'visible','off');
huidiao=[...
        'yearnum=str2num(get(edit1,''string''));,',...
        'monthnum=str2num(get(edit2,''string''));,',...
        'daynum=str2num(get(edit3,''string''));,',...
        'monthday=[0 31 28 31 30 31 30 31 31 30 31 30 31];,',...
        'dyear=yearnum-2000;,',...
        'beishu=fix(dyear/4);,',...
        'yushu=rem(yearnum,4);,',...
        'if yushu==0,',...
        'monthday(3)=29;,',...
        'end,',...
        'mday=0;,',...
        'for i=1:monthnum,',...
        'mday=monthday(i)+mday;,',...
        'end,',...
        'yearday=mday+daynum-1;,',...
        'noweek=fix(yearday/7);,',...
        'set(edit5,''string'',[''第'',num2str(noweek),''周'']);,',...
        'if dyear>0,',...
        'if yushu==0,',...
        'beishu=beishu-1;,',...
        'end,',...
        'dday=yearday+365*dyear+beishu+1;,',...
        'end,',...
        'if dyear<=0,',...
        'dday=365*dyear+yearday+beishu;,',...
        'end,',...
        'mweek=rem(dday,7)+7;,',...
        'if mweek==8,',...
        'set(edit4,''string'',''Sunday'');,',...
        'end,',...
        'if mweek==9,',...
        'set(edit4,''string'',''Monday'');,',...
        'end,',...
        'if mweek==10,',...
        'set(edit4,''string'',''Tuesday'');,',...
        'end,',...
        'if mweek==11,',...
        'set(edit4,''string'',''Wednesday'');,',...
        'end,',...
        'if mweek==12,',...
        'set(edit4,''string'',''Thursday'');,',...
        'end,',...
        'if mweek==13,',...
        'set(edit4,''string'',''Friday'');,',...
        'end,',...
        'if mweek==7,',...
        'set(edit4,''string'',''Saturday'');,',...
        'end,',...
        'if mweek==6,',...
        'set(edit4,''string'',''Friday'');,',...
        'end,',...
        'if mweek==5,',...
        'set(edit4,''string'',''Thursday'');,',...
        'end,',...
        'if mweek==4,',...
        'set(edit4,''string'',''Wednesday'');,',...
        'end,',...
        'if mweek==3,',...
        'set(edit4,''string'',''Tuesday'');,',...
        'end,',...
        'if mweek==2,',...
        'set(edit4,''string'',''Monday'');,',...
        'end,',...
        'if mweek==1,',...
        'set(edit4,''string'',''Sunday'');,',...
        'end'];
edit1=uicontrol('parent',h0,...
    'style','edit',...
    'horizontalalignment','right',...
    'position',[40 300 50 20]);
text1=uicontrol('parent',h0,...
    'style','text',...
    'string','年',...
    'horizontalalignment','left',...
    'position',[90 300 50 20]);
edit2=uicontrol('parent',h0,...
    'style','edit',...
    'horizontalalignment','right',...
    'position',[160 300 50 20]);
text2=uicontrol('parent',h0,...
    'style','text',...
    'string','月',...
    'horizontalalignment','left',...
    'position',[210 300 50 20]);
edit3=uicontrol('parent',h0,...
    'style','edit',...
    'horizontalalignment','right',...
    'position',[280 300 50 20]);
text3=uicontrol('parent',h0,...
    'style','text',...
    'string','日',...
    'horizontalalignment','left',...
    'position',[330 300 50 20]);
edit4=uicontrol('parent',h0,...
    'style','edit',...
    'horizontalalignment','left',...
    'position',[210 200 120 20]);
text4=uicontrol('parent',h0,...
    'style','text',...
    'string','查找的日期为',...
    'horizontalalignment','right',...
    'position',[110 200 100 20]);
edit5=uicontrol('parent',h0,...
    'style','edit',...
    'horizontalalignment','left',...
    'position',[210 100 120 20]);
text1=uicontrol('parent',h0,...
    'style','text',...
    'string','该日处于',...
    'horizontalalignment','left',...
    'position',[160 100 50 20]);
button1=uicontrol('parent',h0,...
    'style','pushbutton',...
    'position',[80 40 80 30],...
    'string','开始',...
    'callback',huidiao);
button2=uicontrol('parent',h0,...
    'style','pushbutton',...
    'position',[220 40 80 30],...
    'string','关闭',...
    'callback','close'); 
实例56:图形效果(1)

h0=figure('toolbar','none',...
    'position',[198 56 450 468],...
    'name','实例56');
h1=axes('parent',h0,...
    'position',[0.3 0.45 0.5 0.5],...
    'visible','off');
l1=uimenu(gcf,'label','Draw figure',...
    'tag','l1');
huidiao=[...
        'if get(r1,''value'')==1,',...
        'shading faceted,',...
        'end,',...
        'if get(r2,''value'')==1,',...
        'shading flat,',...
        'end,',...
        'if get(r3,''value'')==1,',...
        'shading interp,',...
        'end,',...
        'k=get(p1,''value'');,',...
        'switch k,',...
        'case 1,',...
        'colormap(''cool''),',...
        'case 2,',...
        'colormap(''spring''),',...
        'case 3,',...
        'colormap(''summer''),',...
        'case 4,',...
        'colormap(''autumn''),',...
        'case 5,',...
        'colormap(''winter''),',...
        'end'];
l11=uimenu('parent',l1,...
    'label','Surface',...
    'tag','l11',...
    'callback',[...
        '[x,y]=meshgrid(-8:0.5:8);,',...
        'r=sqrt(x.^2+y.^2)+eps;,',...
        'z=sin(r)./r;,',...
        'surf(x,y,z),',...
        huidiao]);
l12=uimenu('parent',l1,...
    'label','Mesh',...
    'tag','l12',...
    'callback',[...
        'mesh(peaks),',...
        huidiao]);
l13=uimenu('parent',l1,...
    'label','Membrane',...
    'tag','l13',...
    'callback',[...
        'mesh(membrane),',...
        huidiao]);
f1=uicontrol('parent',h0,...
    'units','points',...
    'listboxtop',0,...
    'position',[12 6 100 101],...
    'style','frame',...
    'tag','f1');
r1=uicontrol('parent',h0,...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'position',[19.5 58.5 72.75 16.5],...
    'string','shading faceted',...
    'style','radiobutton',...
    'tag','r1',...
    'value',1,...
    'callback',[...
        'shading faceted,',...
        'set(r1,''value'',1);,',...
        'set(r2,''value'',0);,',...
        'set(r3,''value'',0);']);
r2=uicontrol('parent',h0,...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'position',[19.5 35.25 78.75 18.75],...
    'string','shading flat',...
    'style','radiobutton',...
    'tag','r2',...
    'value',0,...
    'callback',[...
        'shading flat,',...
        'set(r2,''value'',1);,',...
        'set(r1,''value'',0);,',...
        'set(r3,''value'',0);']);
r3=uicontrol('parent',h0,...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'position',[19.5 12.75 71.25 18.75],...
    'string','shading interp',...
    'style','radiobutton',...
    'tag','r3',...
    'value',0,...
    'callback',[...
        'shading interp,',...
        'set(r3,''value'',1);,',...
        'set(r1,''value'',0);,',...
        'set(r2,''value'',0);']);
t1=uicontrol('parent',h0,...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'fontsize',12,...
    'listboxtop',0,...
    'position',[14.25 75.75 90.75 22.5],...
    'string','平滑处理',...
    'style','text',...
    'tag','t1');
t2=uicontrol('parent',h0,...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'fontsize',12,...
    'listboxtop',0,...
    'position',[117 69 72.75 17.5],...
    'string','设置色调',...
    'style','text',...
    'tag','t2');
p1=uicontrol('parent',h0,...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'position',[116.25 39 72.75 20.25],...
    'string','Cool|Spring|Summer|Autumn|Winter',...
    'style','popupmenu',...
    'tag','p1',...
    'value',1,...
    'callback',[...
        'k=get(p1,''value'');,',...
        'switch k,',...
        'case 1,',...
        'colormap(''cool''),',...
        'case 2,',...
        'colormap(''spring''),',...
        'case 3,',...
        'colormap(''summer''),',...
        'case 4,',...
        'colormap(''autumn''),',...
        'case 5,',...
        'colormap(''winter''),',...
        'end']);
b1=uicontrol('parent',h0,...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'position',[12 243 72.75 30.75],...
    'string','关闭',...
    'tag','b1',...
    'callback','close');
b2=uicontrol('parent',h0,...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'position',[216.75 67.5 83.25 18.75],...
    'string','Colorbar',...
    'tag','b2',...
    'callback','colorbar');
实例57:图形效果

h0=figure('toolbar','none',...
    'position',[168 94.5 315 289.5],...
    'name','实例57');
h1=axes('parent',h0,...
    'position',[0.4 0.4 0.5 0.5],...
    'visible','off');
f1=uicontrol('parent',h0,...
    'style','frame',...
    'position',[15 10 80 70],...
    'string','dull',...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'tag','r1',...
    'value',1,...
    'callback',[...
        'set(r1,''value'',1);,',...
        'set(r2,''value'',0);,',...
        'set(r3,''value'',0);,',...
        'material dull']);
r1=uicontrol('parent',h0,...
    'style','radiobutton',...
    'position',[19.5 58.5 72.75 16.5],...
    'string','dull',...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'tag','r1',...
    'value',1,...
    'callback',[...
        'set(r1,''value'',1);,',...
        'set(r2,''value'',0);,',...
        'set(r3,''value'',0);,',...
        'material dull']);
r2=uicontrol('parent',h0,...
    'style','radiobutton',...
    'position',[19.5 35.25 72.75 16.5],...
    'string','metal',...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'tag','r2',...
    'value',0,...
    'callback',[...
        'set(r2,''value'',1);,',...
        'set(r1,''value'',0);,',...
        'set(r3,''value'',0);,',...
        'material metal']);
r3=uicontrol('parent',h0,...
    'style','radiobutton',...
    'position',[19.5 12.75 72.75 16.5],...
    'string','shiny',...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'tag','r3',...
    'value',0,...
    'callback',[...
        'set(r3,''value'',1);,',...
        'set(r1,''value'',0);,',...
        'set(r2,''value'',0);,',...
        'material shiny']);
u1=uimenu('parent',h0,...
    'label','绘图',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'tag','u1',...
    'callback',[...
        '[x,y]=meshgrid(-8:0.5:8);,',...
        'r=sqrt(x.^2+y.^2)+eps;,',...
        'z=sin(r)./r;,',...
        'surf(x,y,z),',...
        'shading interp']);
b1=uicontrol('parent',h0,...
    'style','pushbutton',...
    'position',[19.5 150 60 20],...
    'string','light',...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'tag','b1',...
    'callback','camlight headlight');
b2=uicontrol('parent',h0,...
    'style','pushbutton',...
    'position',[19.5 100 60 20],...
    'string','关闭',...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'tag','b2',...
    'callback','close');
实例58:可控制小球运动速度的用户界面

h0=figure('toolbar','none',...
    'position',[198 56 350 468],...
    'name','实例58');
h1=axes('parent',h0,...
    'position',[0.25 0.45 0.5 0.5],...
    'visible','off');
t=0:0.1:4*pi;
x=sin(t);
y=cos(t);
plot(x,y)
axis equal
axis off
h=line('color',[1 0 0],...
    'linestyle','.',...
    'xdata',0,...
    'ydata',1,...
    'markersize',20,...
    'erasemode','xor');
n=length(t);
i=1;
speed=0.01;
k=0;
b1huidiao=[...
        'k=0;,',...
        'while 1,',...
        'set(h,''xdata'',x(i),''ydata'',y(i));,',...
        'drawnow,',...
        'pause(speed),',...
        'i=i+1;,',...
        'if i>n,',...
        'i=1;,',...
        'end,',...
        'if k==1,',...
        'break,',...
        'end,',...
        'end'];
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'string','开始',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[30 80 50 20],...
    'callback',b1huidiao);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'style','pushbutton',...
    'string','停止',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[100 80 50 20],...
    'callback','k=1;');
b3=uicontrol('parent',h0,...
    'units','points',...
    'tag','b3',...
    'style','pushbutton',...
    'string','关闭',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[170 80 50 20],...
    'callback',[...
        'k=1;,',...
        'close']);
s1=uicontrol('parent',h0,...
    'units','points',...
    'tag','s1',...
    'style','slider',...
    'value',50*speed,...
    'max',1,...
    'min',0,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[30 115 190 20],...
    'callback',[...
        'm=get(s1,''value'');,',...
        'speed=m/50;']);
t1=uicontrol('parent',h0,...
    'units','points',...
    'tag','t1',...
    'style','text',...
    'fontsize',15,...
    'string','小球运动速度',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[30 135 190 20]); 
实例59:设置坐标轴纵横轴比

h0=figure('name','实例59');
h1=axes('parent',h0,...
    'position',[0.3 0.45 0.5 0.5],...
    'visible','off');
u1=uimenu('parent',h0,...
    'label','绘图',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'tag','u1',...
    'callback',[...
        '[x,y]=meshgrid(-8:0.5:8);,',...
        'r=sqrt(x.^2+y.^2)+eps;,',...
        'z=sin(r)./r;,',...
        'mesh(x,y,z),',...
        'shading interp,',...
        'axis normal']);
f1=uicontrol('parent',h0,...
    'units','points',...
    'listboxtop',0,...
    'position',[12 6 100 150],...
    'style','frame',...
    'tag','f1');
t1=uicontrol('parent',h0,...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'position',[19.5 130 72.75 16.5],...
    'string','坐标纵横比',...
    'style','text',...
    'tag','t1');
r1=uicontrol('parent',h0,...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'position',[19.5 110 72.75 16.5],...
    'string','axis equal',...
    'style','radiobutton',...
    'tag','r1',...
    'value',1,...
    'callback',[...
        'set(r1,''value'',1);,',...
        'set(r2,''value'',0);,',...
        'set(r3,''value'',0);,',...
        'set(r4,''value'',0);,',...
        'set(r5,''value'',0);,',...
        'axis equal']);
r2=uicontrol('parent',h0,...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'position',[19.5 85 72.75 16.5],...
    'string','axis square',...
    'style','radiobutton',...
    'tag','r2',...
    'value',0,...
    'callback',[...
        'set(r2,''value'',1);,',...
        'set(r1,''value'',0);,',...
        'set(r3,''value'',0);,',...
        'set(r4,''value'',0);,',...
        'set(r5,''value'',0);,',...
        'axis square']);
r3=uicontrol('parent',h0,...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'position',[19.5 60 72.75 16.5],...
    'string','axis image',...
    'style','radiobutton',...
    'tag','r3',...
    'value',0,...
    'callback',[...
        'set(r3,''value'',1);,',...
        'set(r2,''value'',0);,',...
        'set(r1,''value'',0);,',...
        'set(r4,''value'',0);,',...
        'set(r5,''value'',0);,',...
        'axis image']);
r4=uicontrol('parent',h0,...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'position',[19.5 35 72.75 16.5],...
    'string','axie vis3d',...
    'style','radiobutton',...
    'tag','r4',...
    'value',0,...
    'callback',[...
        'set(r4,''value'',1);,',...
        'set(r2,''value'',0);,',...
        'set(r3,''value'',0);,',...
        'set(r1,''value'',0);,',...
        'set(r5,''value'',0);,',...
        'axis vis3d']);
r5=uicontrol('parent',h0,...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'position',[19.5 10 72.75 16.5],...
    'string','axis auto',...
    'style','radiobutton',...
    'tag','r5',...
    'value',0,...
    'callback',[...
        'set(r5,''value'',1);,',...
        'set(r2,''value'',0);,',...
        'set(r3,''value'',0);,',...
        'set(r4,''value'',0);,',...
        'set(r1,''value'',0);,',...
        'axis auto']);
b1=uicontrol('parent',h0,...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'position',[12 243 72.75 30.75],...
    'string','关闭',...
    'tag','b1',...
    'callback','close');
b2=uicontrol('parent',h0,...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'position',[216.75 67.5 83.25 18.75],...
    'string','Colorbar',...
    'tag','b2',...
    'callback','colorbar');
实例60:动态文本显示

h0=figure('toolbar','none',...
    'position',[198 56 350 468],...
    'name','实例60');
h1=axes('parent',h0,...
    'position',[0.25 0.45 0.5 0.5],...
    'visible','off');
str1='当前阻尼比=';
z=0.52;
t=0:0.1:10;
y=step(1,[1 2*z 1],t);
hline=plot(t,y);
grid on
r1=uicontrol('parent',h0,...
    'units','points',...
    'tag','r1',...
    'style','radio',...
    'string','grid on',...
    'position',[30 120 60 20],...
    'backgroundcolor',[0.75 0.75 0.75],...
    'value',1,...
    'callback',[...
        'grid on,',...
        'set(r1,''value'',1);,',...
        'set(r2,''value'',0)']);
r2=uicontrol('parent',h0,...
    'units','points',...
    'tag','r2',...
    'style','radio',...
    'string','grid on',...
    'position',[30 95 60 20],...
     'backgroundcolor',[0.75 0.75 0.75],...
    'value',0,...
    'callback',[...
        'grid off,',...
        'set(r2,''value'',1);,',...
        'set(r1,''value'',0)']);
s1=uicontrol('parent',h0,...
    'units','points',...
    'tag','s1',...
    'style','slider',...
    'value',z,...
    'position',[100 95 150 20],...
     'backgroundcolor',[0.75 0.75 0.75],...
    'max',1,...
    'min',0,...
    'callback',[...
        'z=get(s1,''value'');,',...
        'set(t1,''string'',[str1,sprintf(''%1.4g\'',z)]);,',...
        'delete(hline),',...
        'y=step(1,[1 2*z 1],t);,',...
        'hline=plot(t,y);,',...
        'if get(r1,''value'')==1,',...
        'grid on,',...
        'end,',...
        'if get(r2,''value'')==1,',...
        'grid off,',...
        'end']);
t1=uicontrol('parent',h0,...
    'units','points',...
    'tag','t1',...
    'style','text',...
    'string',[str1,sprintf('%1.4g\',z)],...
    'position',[100 120 150 20],...
    'backgroundcolor',[0.75 0.75 0.75]);
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'string','关闭',...
    'position',[80 50 80 30],...
    'backgroundcolor',[0.75 0.75 0.75],...
    'fontsize',15,...
    'callback','close');
实例61:浏览流体数据

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');
实例62:简单计算器

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;
实例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',...
    '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
实例65:时间计算器

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]);
实例66:数字操作

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'); 
实例67:图像的块操作

h0=figure('toolbar','none',...
    'position',[198 56 350 468],...
    'name','实例67');
h1=axes('parent',h0,...
    'position',[0.2 0.45 0.6 0.5],...
    'visible','off');
I=imread('tire.tif');
imshow(I)
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'style','pushbutton',...
    'string','边沿操作',...
    'position',[30 100 50 20],...
    'callback',[...
        'cla,',...
        'I=imread(''tire.tif'');,',...
        'f=inline(''max(x(:))'');,',...
        'I2=nlfilter(I,[2 2],f);,',...
        'imshow(I2)']);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'style','pushbutton',...
    'string','显示块操作',...
    'position',[100 100 50 20],...
    'callback',[...
        'cla,',...
        'I=imread(''tire.tif'');,',...
        'f=inline(''uint8(round(mean2(x)*ones(size(x))))'');,',...
        'I2=blkproc(I,[6 6],f);,',...
        'imshow(I2)']);
b3=uicontrol('parent',h0,...
    'units','points',...
    'tag','b3',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'style','pushbutton',...
    'string','交叠块操作',...
    'position',[170 100 50 20],...
    'callback',[...
        'cla,',...
        'I=imread(''tire.tif'');,',...
        'f=inline(''uint8(round(mean2(x)*ones(size(x))))'');,',...
        'I2=blkproc(I,[6 6],[3 3],f);,',...
        'imshow(I2)']);
b4=uicontrol('parent',h0,...
    'units','points',...
    'tag','b4',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'style','pushbutton',...
    'string','关闭',...
    'fontsize',14,...
    'position',[90 50 70 30],...
    'callback','close');
实例68:图形的过滤操作

h0=figure('toolbar','none',...
    'position',[198 56 350 468],...
    'name','过滤操作');
h1=axes('parent',h0,...
    'position',[0.3 0.45 0.5 0.5],...
    'visible','off');
I=imread('blood1.tif');
imshow(I)
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'string','均平过滤',...
    'position',[50 120 50 20],...
    'callback',[...
        'cla,',...
        'I=imread(''blood1.tif'');,',...
        'h=fspecial(''average'',6);,',...
        'I2=uint8(round(filter2(h,I)));,',...
        'imshow(I2)']);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'style','pushbutton',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'string','Sobel过滤',...
    'position',[150 120 50 20],...
    'callback',[...
        'cla,',...
        'I=imread(''blood1.tif'');,',...
        'h=fspecial(''sobel'');,',...
        'I2=filter2(h,I);,',...
        'imshow(I2,[])']);
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'string','关闭',...
    'position',[85 60 80 30],...
    'callback','close'); 
实例69:图像的频率操作

h0=figure('toolbar','none',...
    'position',[198 56 350 468],...
    'name','频率操作');
h1=axes('parent',h0,...
    'position',[0.3 0.45 0.5 0.5],...
    'visible','off');
b=remez(10,[0 0.4 0.6 1],[1 1 0 0]);
h=ftrans2(b);
[H,W]=freqz(b,1,64,'whole');
colormap(jet(64))
plot(W/pi-1,fftshift(abs(H)))
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'style','pushbutton',...
    'string','频率变换',...
    'position',[30 100 50 20],...
    'callback',[...
        'cla,',...
        'b=remez(10,[0 0.4 0.6 1],[1 1 0 0]);,',...
        'h=ftrans2(b);,',...
        '[H,W]=freqz(b,1,64,''whole'');,',...
        'colormap(jet(64)),',...
        'freqz2(h,[32 32])']);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'style','pushbutton',...
    'string','频率采样一',...
    'position',[100 100 50 20],...
    'callback',[...
        'cla,',...
        'Hd=zeros(11,11);,',...
        'Hd(4:8,4:8)=1;,',...
        '[f1,f2]=freqspace(11,''meshgrid'');,',...
        'mesh(f1,f2,Hd),',...
        'axis([-1 1 -1 1 0 1.2]),',...
        'colormap(jet(64))']);
b3=uicontrol('parent',h0,...
    'units','points',...
    'tag','b3',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'style','pushbutton',...
    'string','频率采样二',...
    'position',[170 100 50 20],...
    'callback',[...
        'cla,',...
        'Hd=zeros(11,11);,',...
        'Hd(4:8,4:8)=1;,',...
        'H=fsamp2(Hd);,',...
        'freqz2(h,[32 32]),',...
        'axis([-1 1 -1 1 0 1.2]),',...
        'colormap(jet(64))']);
b4=uicontrol('parent',h0,...
    'units','points',...
    'tag','b4',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'style','pushbutton',...
    'string','关闭',...
    'fontsize',15,...
    'position',[80 50 80 30],...
    'callback','close');
实例70:函数变换

h0=figure('toolbar','none',...
    'position',[198 56 350 468],...
    'name','函数变换');
h1=axes('parent',h0,...
    'position',[0.25 0.45 0.5 0.5],...
    'visible','off');
I=imread('cameraman.tif');
imshow(I)
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'style','pushbutton',...
    'string','图像压缩',...
    'position',[30 100 50 20],...
    'callback',[...
        'cla,',...
        'I=imread(''cameraman.tif'');,',...
        'I2=im2double(I);,',...
        'imshow(I2)']);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'style','pushbutton',...
    'string','图像解压',...
    'position',[100 100 50 20],...
    'callback',[...
        'cla,',...
        'I=imread(''cameraman.tif'');,',...
        'I=im2double(I);,',...
        'T=dctmtx(8);,',...
        'B=blkproc(I,[8 8],''P1*x*P2'',T,T'');,',...
        'mask=[1 1 1 1 0 0 0 0;,',...
              '1 1 1 0 0 0 0 0;,',...
              '1 1 0 0 0 0 0 0;,',...
              '1 0 0 0 0 0 0 0;,',...
              '0 0 0 0 0 0 0 0;,',...
              '0 0 0 0 0 0 0 0;,',...
              '0 0 0 0 0 0 0 0;,',...
              '0 0 0 0 0 0 0 0];,',...
        'B2=blkproc(B,[8 8],''P1.*x'',mask);,',...
        'I2=blkproc(B2,[8 8],''P1*x*P2'',T'',T);,',...
        'imshow(I2)']);
b3=uicontrol('parent',h0,...
    'units','points',...
    'tag','b3',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'style','pushbutton',...
    'string','线条解析',...
    'position',[170 100 50 20],...
    'callback',[...
        'cla,',...
        'I=imread(''cameraman.tif'');,',...
        'BW=edge(I);,',...
        'imshow(BW)']);
b4=uicontrol('parent',h0,...
    'units','points',...
    'tag','b4',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'style','pushbutton',...
    'string','关闭',...
    'fontsize',15,...
    'position',[80 50 80 30],...
    'callback','close');
实例71:RADON函数变换

h0=figure('toolbar','none',...
    'position',[198 56 350 468],...
    'name','实例71');
h1=axes('parent',h0,...
    'position',[0.3 0.45 0.5 0.5],...
    'visible','off');
P=phantom(256);
imshow(P)
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'string','变换一',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[30 100 50 20],...
    'callback',[...
        'cla,',...
        'k=1;,',...
        'theta1=0:10:170;,',...
        'R1=radon(P,theta1);,',...
        'imagesc(R1),',...
        'colormap(hot),',...
        'colorbar']);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'style','pushbutton',...
    'string','变换二',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[100 100 50 20],...
    'callback',[...
        'cla,',...
        'k=2;,',...
        'theta2=0:5:175;,',...
        'R2=radon(P,theta2);,',...
        'imagesc(R2),',...
        'colormap(hot),',...
        'colorbar']);
b3=uicontrol('parent',h0,...
    'units','points',...
    'tag','b3',...
    'style','pushbutton',...
    'string','变换三',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[170 100 50 20],...
    'callback',[...
        'cla,',...
        'k=3;,',...
        'theta3=0:2:178;,',...
        'R3=radon(P,theta3);,',...
        'imagesc(R3),',...
        'colormap(hot),',...
        'colorbar']);
b4=uicontrol('parent',h0,...
    'units','points',...
    'tag','b4',...
    'style','pushbutton',...
    'string','原始图像',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[50 50 70 30],...
    'callback',[...
        'cla,',...
        'if k==1,',...
        'I1=iradon(R1,10);,',...
        'imshow(I1),',...
        'end,',...
        'if k==2,',...
        'I2=iradon(R2,5);,',...
        'imshow(I2),',...
        'end,',...
        'if k==3,',...
        'I3=iradon(R3,2);,',...
        'imshow(I3),',...
        'end']);        
b5=uicontrol('parent',h0,...
    'units','points',...
    'tag','b5',...
    'style','pushbutton',...
    'string','关闭',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[150 50 70 30],...
    'callback','close');