数模论坛

 找回密码
 注-册-帐-号
搜索
热搜: 活动 交友 discuz
楼主: 宝宝

【编程学习】matlab实用程序百例

  [复制链接]
 楼主| 发表于 2004-6-1 18:40:38 | 显示全部楼层
<><FONT size=1><b><EM>实例81:MRI数据的显示</EM></b></FONT></P><>load mri
D = squeeze(D);
h0=figure('toolbar','none',...
    'position',[198 56 450 468],...
    'name','实例81');
h1=axes('parent',h0,...
    'position',[0.3 0.45 0.5 0.5],...
    'visible','off');
image_num = 8;
image(D(:,:,image_num))
axis image
colormap(map)
x = xlim;
y = ylim;
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[50 100 60 20],...
    'string','二维图',...
    'callback',[...
        'cla,',...
        'contourslice(D,[],[],image_num),',...
        'axis ij,',...
        'xlim(x),',...
        'ylim(y),',...
        'daspect([1,1,1]),',...
        'colormap(''default'')']);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'style','pushbutton',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[250 100 60 20],...
    'string','三维图',...
    'callback',[...
        'cla,',...
        'phandles = contourslice(D,[],[],[1,12,19,27],8);,',...
        'view(3);,',...
        'axis tight,',...
        'set(phandles,''LineWidth'',2)']);
b3=uicontrol('parent',h0,...
    'units','points',...
    'tag','b3',...
    'style','pushbutton',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[50 50 60 20],...
    'string','立体图',...
    'callback',[...
        'cla,',...
        'Ds = smooth3(D);,',...
        'hiso = patch(isosurface(Ds,5),''FaceColor'',[1,.75,.65],''EdgeColor'',''none'');,',...
        'hcap = patch(isocaps(D,5),''FaceColor'',''interp'',''EdgeColor'',''none'');,',...
        'colormap(map),',...
        'view(45,30),',...
        'axis tight,',...
        'daspect([1,1,.4]),',...
        'lightangle(45,30),',...
        'lighting phong,',...
        'isonormals(Ds,hiso),',...
        'set(hcap,''AmbientStrength'',.6),',...
        'set(hiso,''SpecularColorReflectance'',0,''SpecularExponent'',50)']);
b4=uicontrol('parent',h0,...
    'units','points',...
    'tag','b4',...
    'style','pushbutton',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[250 50 60 20],...
    'string','关闭',...
    'callback','close');
</P>
 楼主| 发表于 2004-6-1 18:41:11 | 显示全部楼层
<><FONT size=1><b><EM>实例82:图像类型转换</EM></b></FONT></P><>h0=figure('toolbar','none',...
    'position',[198 56 350 468],...
    'name','实例82');
h1=axes('parent',h0,...
    'position',[0.2 0.45 0.5 0.5],...
    'visible','off');
load earth
clims = [10 60];
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'string','强度图像',...
    'position',[30 120 50 20],...
    'callback',[...
        'cla,',...
        'imagesc(X,clims),',...
        'colormap(gray)']);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'style','pushbutton',...
    'string','索引图像',...
    'position',[100 120 50 20],...
    'callback',[...
        'cla,',...
        'image(X),',...
        'colormap(map),',...
        'axis image']);
b3=uicontrol('parent',h0,...
    'units','points',...
    'tag','b3',...
    'style','pushbutton',...
    'string','真彩图像',...
    'position',[170 120 50 20],...
    'callback',[...
        'cla,',...
        'image(X),',...
        'axis image']);
b4=uicontrol('parent',h0,...
    'units','points',...
    'tag','b4',...
    'style','pushbutton',...
    'string','关闭',...
    'position',[100 50 50 20],...
    'callback','close');
</P>
 楼主| 发表于 2004-6-1 18:41:40 | 显示全部楼层
<><FONT size=1><b><EM>实例83:特殊的图像显示技术</EM></b></FONT></P><>h0=figure('toolbar','none',...
    'position',[198 56 350 468],...
    'name','实例83');
h1=axes('parent',h0,...
    'position',[0.25 0.45 0.5 0.5],...
    'visible','off');
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'style','pushbutton',...
    'string','颜色条',...
    'position',[30 120 50 20],...
    'callback',[...
        'cla,',...
        'I = imread(''plane.jpg'');,',...
        'imshow(I),',...
        'colorbar']);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'style','pushbutton',...
    'position',[100 120 50 20],...
    'string','单帧显示',...
    'callback',[...
        'cla,',...
        'load mri,',...
        'imshow(D(:,:,:,7))']);
b3=uicontrol('parent',h0,...
    'units','points',...
    'tag','b3',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'style','pushbutton',...
    'string','动画显示',...
    'position',[30 60 50 20],...
    'callback',[...
        'cla,',...
        'load mri,',...
        'montage(D,map),',...
        'mov=immovie(D,map);,',...
        'colormap(map),',...
        'movie(mov)']);
b4=uicontrol('parent',h0,...
    'units','points',...
    'tag','b4',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'style','pushbutton',...
    'string','纹理映射',...
    'position',[170 60 50 20],...
    'callback',[...
        'cla,',...
        '[x,y,z] = cylinder;,',...
        'I = imread(''girls.jpg'');,',...
        'warp(x,z,y,I);']);
b5=uicontrol('parent',h0,...
    'units','points',...
    'tag','b5',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'style','pushbutton',...
    'string','关闭',...
    'position',[100 60 50 20],...
    'callback','close');
b6=uicontrol('parent',h0,...
    'units','points',...
    'tag','b6',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'style','pushbutton',...
    'string','多帧显示',...
    'position',[170 120 50 20],...
    'callback',[...
        'cla,',...
        'load mri,',...
        'montage(D,map)']);</P>
 楼主| 发表于 2004-6-1 18:42:10 | 显示全部楼层
<><FONT size=1><b><EM>实例84:图像的几何操作</EM></b></FONT></P><>h0=figure('toolbar','none',...
    'position',[198 56 400 468],...
    'name','实例84');
h1=axes('parent',h0,...
    'position',[0.25 0.45 0.5 0.5],...
    'visible','off');
I=imread('plane.jpg','jpg');
imshow(I)
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'style','pushbutton',...
    'string','图像旋转',...
    'position',[200 120 50 20],...
    'callback',[...
        'cla,',...
        'k=str2num(get(e1,''string''));,',...
        'I=imread(''plane.jpg'',''jpg'');,',...
        'J=imrotate(I,k,''bilinear'');,',...
        'imshow(J)']);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'style','pushbutton',...
    'string','图像剪切',...
    'position',[200 80 50 20],...
    'callback',[...
        'cla,',...
        'imshow plane.jpg,',...
        'I=imcrop;,',...
        'imshow(I)']);
  b3=uicontrol('parent',h0,...
    'units','points',...
    'tag','b3',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'style','pushbutton',...
    'string','关闭',...
    'position',[120 30 50 20],...
    'callback','close');
e1=uicontrol('parent',h0,...
    'units','points',...
    'tag','e1',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'style','edit',...
    'horizontalalignment','right',...
    'position',[50 80 100 20]);
t1=uicontrol('parent',h0,...
    'units','points',...
    'tag','t1',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'style','text',...
    'string','请输入旋转角度(0~90)度',...
    'fontsize',12,...
    'position',[40 100 130 20]);</P>
 楼主| 发表于 2004-6-1 18:42:50 | 显示全部楼层
<><FONT size=1><b><EM>实例85:拉个朗日插值</EM></b></FONT></P><>h0=figure('toolbar','none',...
    'position',[200 50 350 450],...
    'name','实例85');
h1=axes('parent',h0,...
    'position',[0.10 0.45 0.8 0.5],...
    'visible','off');
x=0:0.2:2*pi;
y=sin(x);
plot(x,y)
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'string','拉格朗日插值',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[20 60 70 20],...
    'callback',[...
        'cla,',...
        'strn=get(e1,''string'');,',...
        'n=str2num(strn);,',...
        'i=1;,',...
        'x=0:0.2:2*pi;,',...
        'for t=0:0.2:2*pi,',...
        'y(i)=sin(t);,',...
        'L(i)=lag(t,n);,',...
        'i=i+1;,',...
        'end,',...
        'plot(x,y,''b*'',x,L,''r-''),',...
        'legend(''sin(x)'',''插值函数'');,',...
        'axis([0 7 -1.5 1.5])']);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'style','pushbutton',...
    'string','误差比较',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[170 60 70 20],...
    'callback',[...
        'strn=get(e1,''string'');,',...
        'n=str2num(strn);,',...
        'strm=get(e2,''string'');,',...
        'm=str2num(strm);,',...
        'dd=abs(sin(m)-lag(m,n));,',...
        'msgbox([''误差为:'',num2str(dd)],''计算结果'')']);
e1=uicontrol('parent',h0,...
    'units','points',...
    'tag','e1',...
    'style','edit',...
    'fontsize',12,...
    'string','5',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[50 100 40 20]);
e2=uicontrol('parent',h0,...
    'units','points',...
    'tag','e2',...
    'style','edit',...
    'fontsize',12,...
    'string','1.20',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[200 100 40 20]);
t1=uicontrol('parent',h0,...
    'units','points',...
    'tag','t1',...
    'style','text',...
    'string','阶数:',...
    'fontsize',12,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[20 100 30 20]);
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','误差点:',...
    'fontsize',12,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[160 100 40 20]);
b3=uicontrol('parent',h0,...
    'units','points',...
    'tag','b3',...
    'style','pushbutton',...
    'string','关闭',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[100 20 60 20],...
    'callback','close');</P>
 楼主| 发表于 2004-6-1 18:43:30 | 显示全部楼层
<><FONT size=1><b><EM>实例86:三次样条插值法</EM></b></FONT></P><>h0=figure('toolbar','none',...
    'position',[200 50 350 450],...
    'name','实例86');
h1=axes('parent',h0,...
    'position',[0.10 0.45 0.8 0.5],...
    'visible','off');
x=0:0.2:2*pi;
y=sin(x);
plot(x,y)
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'string','三次样条插值',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[20 60 70 20],...
    'callback',[...
        'y=0,',...
        'sy=0,',...
        'strn1=get(e2,''string'');,',...
        'n1=str2num(strn1);,',...
        'strn2=get(e3,''string'');,',...
        'n2=str2num(strn2);,',...
        'x=n1:0.2:n2;,',...
        'i=1;,',...
        'for t=n1:0.2:n2,',...
        'y(i)=sin(t);,',...
        'sy(i)=san(t,n1,n2);,',...
        'i=i+1;,',...
        'end,',...
        'plot(x,y,''b*'',x,sy,''r-''),',...
        'axis([0 7 -1.5 1.5]),',...
        'legend(''sin(x)'',''N-Hermite插值'')']);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'style','pushbutton',...
    'string','误差比较',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[170 60 70 20],...
    'callback',[...
        'strdn1=get(e2,''string'');,',...
        'n1=str2num(strdn1);,',...
        'strdn2=get(e3,''string'');,',...
        'n2=str2num(strdn2);,',...
        'strdn=get(e1,''string'');,',...
        'dn=str2num(strdn);,',...
        'dd=abs(sin(dn)-san(dn,n1,n2));,',...
        'msgbox([''误差为:'',num2str(dd)],''计算结果'')']);
e1=uicontrol('parent',h0,...
    'units','points',...
    'tag','e1',...
    'style','edit',...
    'fontsize',12,...
    'string','1.20',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[200 100 40 20]);
t1=uicontrol('parent',h0,...
    'units','points',...
    'tag','t1',...
    'style','text',...
    'string','误差点:',...
    'fontsize',12,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[160 100 40 20]);
e2=uicontrol('parent',h0,...
    'units','points',...
    'tag','e2',...
    'style','edit',...
    'fontsize',12,...
    'string','1.00',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[20 85 40 20]);
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','第一节点:',...
    'fontsize',12,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[15 105 50 20]);
e3=uicontrol('parent',h0,...
    'units','points',...
    'tag','e3',...
    'style','edit',...
    'fontsize',12,...
    'string','3.00',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[100 85 40 20]);
t3=uicontrol('parent',h0,...
    'units','points',...
    'tag','t3',...
    'style','text',...
    'string','第二节点:',...
    'fontsize',12,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[95 105 50 20]);
b3=uicontrol('parent',h0,...
    'units','points',...
    'tag','b3',...
    'style','pushbutton',...
    'string','关闭',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[100 20 60 20],...
    'callback','close');</P>
 楼主| 发表于 2004-6-1 18:44:01 | 显示全部楼层
<><FONT size=1><b><EM>实例87:NEWTON插值</EM></b></FONT></P><>h0=figure('toolbar','none',...
    'position',[200 50 350 450],...
    'name','实例87');
h1=axes('parent',h0,...
    'position',[0.10 0.45 0.8 0.5],...
    'visible','off');
x=0:0.2:2*pi;
y=sin(x);
plot(x,y)
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'string','牛顿插值',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[20 60 70 20],...
    'callback',[...
        'strn=get(e1,''string'');,',...
        'n=str2num(strn);,',...
        'x=0:0.2:2*pi;,',...
        'i=1;,',...
        'for t=0:0.2:2*pi,',...
        'y(i)=sin(t);,',...
        'ynt(i)=newton(t,n);,',...
        'i=i+1;,',...
        'end,',...
        'plot(x,y,''b*'',x,ynt,''r-''),',...
        'axis([0 7 -1.5 1.5]),',...
        'legend(''sin(x)'',''牛顿插值'')']);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'style','pushbutton',...
    'string','误差比较',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[170 60 70 20],...
    'callback',[...
        'strn=get(e1,''string'');,',...
        'n=str2num(strn);,',...
        'strdn=get(e2,''string'');,',...
        'dn=str2num(strdn);,',...
        'dd=abs(sin(dn)-newton(dn,n));,',...
        'msgbox([''误差为:'',num2str(dd)],''计算结果'')']);
e1=uicontrol('parent',h0,...
    'units','points',...
    'tag','e1',...
    'style','edit',...
    'fontsize',12,...
    'string','5',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[50 100 40 20]);
e2=uicontrol('parent',h0,...
    'units','points',...
    'tag','e2',...
    'style','edit',...
    'fontsize',12,...
    'string','1.20',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[200 100 40 20]);
t1=uicontrol('parent',h0,...
    'units','points',...
    'tag','t1',...
    'style','text',...
    'string','节点数:(&lt;6)',...
    'fontsize',12,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[10 100 40 30]);
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','误差点:',...
    'fontsize',12,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[160 100 40 20]);
b3=uicontrol('parent',h0,...
    'units','points',...
    'tag','b3',...
    'style','pushbutton',...
    'string','关闭',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[100 20 60 20],...
    'callback','close');</P>
 楼主| 发表于 2004-6-1 18:44:33 | 显示全部楼层
<><FONT size=1><b><EM>实例88:hermite插值</EM></b></FONT></P><>h0=figure('toolbar','none',...
    'position',[200 50 350 450],...
    'name','实例88');
h1=axes('parent',h0,...
    'position',[0.10 0.45 0.8 0.5],...
    'visible','off');
x=0:0.2:2*pi;
y=sin(x);
plot(x,y)
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'string','Hermite插值',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[20 60 70 20],...
    'callback',[...
        'strn1=get(e2,''string'');,',...
        'n1=str2num(strn1);,',...
        'strn2=get(e3,''string'');,',...
        'n2=str2num(strn2);,',...
        'x=0:0.2:2*pi;,',...
        'i=1;,',...
        'for t=0:0.2:2*pi,',...
        'y(i)=sin(t);,',...
        'ynt(i)=hermite(t,n1,n2);,',...
        'i=i+1;,',...
        'end,',...
        'plot(x,y,''b*'',x,ynt,''r-''),',...
        'axis([0 7 -1.5 1.5]),',...
        'legend(''sin(x)'',''Hermite插值'')']);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'style','pushbutton',...
    'string','误差比较',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[170 60 70 20],...
    'callback',[...
        'strn1=get(e2,''string'');,',...
        'n1=str2num(strn1);,',...
        'strn2=get(e3,''string'');,',...
        'n2=str2num(strn2);,',...
        'dn=str2num(strdn);,',...
        'dd=abs(sin(dn)-hermite(dn,n1,n2));,',...
        'msgbox([''误差为:'',num2str(dd)],''计算结果'')']);
e1=uicontrol('parent',h0,...
    'units','points',...
    'tag','e1',...
    'style','edit',...
    'fontsize',12,...
    'string','1.20',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[200 100 40 20]);
t1=uicontrol('parent',h0,...
    'units','points',...
    'tag','t1',...
    'style','text',...
    'string','误差点:',...
    'fontsize',12,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[160 100 40 20]);
e2=uicontrol('parent',h0,...
    'units','points',...
    'tag','e2',...
    'style','edit',...
    'fontsize',12,...
    'string','1.00',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[20 85 40 20]);
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','第一节点:',...
    'fontsize',12,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[15 105 50 20]);
e3=uicontrol('parent',h0,...
    'units','points',...
    'tag','e3',...
    'style','edit',...
    'fontsize',12,...
    'string','3.00',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[100 85 40 20]);
t3=uicontrol('parent',h0,...
    'units','points',...
    'tag','t3',...
    'style','text',...
    'string','第二节点:',...
    'fontsize',12,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[95 105 50 20]);
b3=uicontrol('parent',h0,...
    'units','points',...
    'tag','b3',...
    'style','pushbutton',...
    'string','关闭',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[100 20 60 20],...
    'callback','close');</P>
 楼主| 发表于 2004-6-1 18:45:15 | 显示全部楼层
<><FONT size=1><b>实例89:mewton形式的hermite插值</b></FONT></P><>h0=figure('toolbar','none',...
    'position',[200 50 350 450],...
    'name','实例89');
h1=axes('parent',h0,...
    'position',[0.10 0.45 0.8 0.5],...
    'visible','off');
x=0:0.2:2*pi;
y=sin(x);
plot(x,y)
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'string','N-Hermite插值',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[20 60 70 20],...
    'callback',[...
        'strn1=get(e2,''string'');,',...
        'n1=str2num(strn1);,',...
        'strn2=get(e3,''string'');,',...
        'n2=str2num(strn2);,',...
        'x=0:0.2:2*pi;,',...
        'i=1;,',...
        'for t=0:0.2:2*pi,',...
        'y(i)=sin(t);,',...
        'ynh(i)=nhermite(t,n1,n2);,',...
        'i=i+1;,',...
        'end,',...
        'plot(x,y,''b*'',x,ynh,''r-''),',...
        'axis([0 7 -1.5 1.5]),',...
        'legend(''sin(x)'',''N-Hermite插值'')']);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'style','pushbutton',...
    'string','误差比较',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[170 60 70 20],...
    'callback',[...
        'strdn1=get(e2,''string'');,',...
        'n1=str2num(strdn1);,',...
        'strdn2=get(e3,''string'');,',...
        'n2=str2num(strdn2);,',...
        'strdn=get(e1,''string'');,',...
        'dn=str2num(strdn);,',...
        'dd=abs(sin(dn)-nhermite(dn,n1,n2));,',...
        'msgbox([''误差为:'',num2str(dd)],''计算结果'')']);
e1=uicontrol('parent',h0,...
    'units','points',...
    'tag','e1',...
    'style','edit',...
    'fontsize',12,...
    'string','1.20',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[200 100 40 20]);
t1=uicontrol('parent',h0,...
    'units','points',...
    'tag','t1',...
    'style','text',...
    'string','误差点:',...
    'fontsize',12,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[160 100 40 20]);
e2=uicontrol('parent',h0,...
    'units','points',...
    'tag','e2',...
    'style','edit',...
    'fontsize',12,...
    'string','1.00',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[20 85 40 20]);
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','第一节点:',...
    'fontsize',12,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[15 105 50 20]);
e3=uicontrol('parent',h0,...
    'units','points',...
    'tag','e3',...
    'style','edit',...
    'fontsize',12,...
    'string','3.00',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[100 85 40 20]);
t3=uicontrol('parent',h0,...
    'units','points',...
    'tag','t3',...
    'style','text',...
    'string','第二节点:',...
    'fontsize',12,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[95 105 50 20]);
b3=uicontrol('parent',h0,...
    'units','points',...
    'tag','b3',...
    'style','pushbutton',...
    'string','关闭',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[100 20 60 20],...
    'callback','close');</P>
 楼主| 发表于 2004-6-1 18:45:57 | 显示全部楼层
<><FONT size=1><b><EM>实例90:平方根法</EM></b></FONT></P><>h0=figure('toolbar','none',...
    'position',[200 150 450 250]);
h1=axes('parent',h0,...
    'position',[0.05 0.15 0.65 0.6],...
    'visible','off');
I=imread('abmatrix.bmp','bmp');
image(I)
axis off
huidiao=[...
        'a=[1 0 3 0;0 2 1 2;3 1 15 0;0 2 0 4;];,',...
        'b=[1 6 5 8]'';,',...
        'r=[a,b];,',...
        'n=4;,',...
        'tic,',...
        'x=ch(a,b,n);,',...
        'time1=toc;,',...
        'T=num2str(time1);,',...
        'set(e1,''string'',[T,''秒'']);,',...
        'msgbox([''X=['',num2str(x(1)),num2str(x(2)),num2str(x(3)),num2str(x(4)),'']''],''方程组的解'');'];
t1=uicontrol('parent',h0,...
    'units','points',...
    'tag','t1',...
    'style','text',...
    'string','方程组如下:',...
    'fontsize',15,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[20 150 100 20]);
e1=uicontrol('parent',h0,...
    'units','points',...
    'tag','e1',...
    'style','edit',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[290 100 30 20]);
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','计算时间:',...
    'fontsize',15,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[250 125 80 20]);
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'string','平方根法',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[250 60 60 20],...
    'callback',huidiao);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'string','关闭',...
    'style','pushbutton',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[250 30 60 20],...
    'callback','close');</P>
您需要登录后才可以回帖 登录 | 注-册-帐-号

本版积分规则

小黑屋|手机版|Archiver|数学建模网 ( 湘ICP备11011602号 )

GMT+8, 2024-5-10 05:53 , Processed in 0.055277 second(s), 12 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表