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

    实例72:图像分析(1)

h0=figure('toolbar','none',...
    'position',[198 56 350 468],...
    'name','实例72');
h1=axes('parent',h0,...
    'position',[0.25 0.45 0.5 0.5],...
    'visible','off');
I=imread('rice.tif');
imshow(I)
k=0;
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'string','图像轮廓图',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[20 100 60 20],...
    'callback',[...
        'cla,',...
        'k=1;,',...
        'I=imread(''rice.tif'');,',...
        'imcontour(I)']);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'style','pushbutton',...
    'string','SOBEL边界图',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[100 100 60 20],...
    'callback',[...
        'cla,',...
        'k=2;,',...
        'I=imread(''rice.tif'');,',...
        'BW=edge(I,''sobel'');,',...
        'imshow(BW)']);
b3=uicontrol('parent',h0,...
    'units','points',...
    'tag','b3',...
    'style','pushbutton',...
    'string','CANNY边界图',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[180 100 60 20],...
    'callback',[...
       'cla,',...
        'k=3;,',...
        'I=imread(''rice.tif'');,',...
        'BW=edge(I,''canny'');,',...
        'imshow(BW)']);
b4=uicontrol('parent',h0,...
    'units','points',...
    'tag','b4',...
    'style','pushbutton',...
    'string','灰度调整',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[20 50 60 20],...
    'callback',[...
        'cla,',...
        'k=4;,',...
        'I=imread(''rice.tif'');,',...
        'J=imadjust(I,[0.15 0.9],[0 1]);,',...
        'imshow(J,64)']);
b5=uicontrol('parent',h0,...
    'units','points',...
    'tag','b5',...
    'style','pushbutton',...
    'string','图像柱状图',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[180 50 60 20],...
    'callback',[...
        'if k==0,',...
        'figure,',...
        'imhist(I,64),',...
        'end,',...
        'if k==1,',...
        'imhist(I,64),',...
        'end,',...
        'if k==2,',...
        'imhist(BW,64),',...
        'end,',...
        'if k==3,',...
        'imhist(BW,64),',...
        'end,',...
        'if k==4,',...
        'imhist(J),',...
        'end']);
b6=uicontrol('parent',h0,...
    'units','points',...
    'tag','b6',...
    'style','pushbutton',...
    'string','关闭',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[100 50 60 20],...
    'callback','close');
实例73:过滤图像

h0=figure('toolbar','none',...
    'position',[198 56 350 468],...
    'name','实例73');
h1=axes('parent',h0,...
    'position',[0.25 0.45 0.5 0.5],...
    'visible','off');
I=imread('eight.tif');
imshow(I)
u1=uimenu('parent',h0,...
    'tag','u1',...
    'label','添加噪声',...
    'backgroundcolor',[0.75 0.75 0.75]);
u11=uimenu('parent',u1,...
    'tag','u11',...
    'label','SALT&PEPPER噪声',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'callback',[...
        'set(u11,''checked'',''on'');,',...
        'set(u12,''checked'',''off'');,',...
        'cla,',...
        'I=imnoise(I,''salt & pepper'',0.02);,',...
        'imshow(I)']);
u12=uimenu('parent',u1,...
    'tag','u12',...
    'label','GAUSSIAN噪声',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'callback',[...
        'set(u12,''checked'',''on'');,',...
        'set(u11,''checked'',''off'');,',...
        'cla,',...
        'I=imnoise(I,''gaussian'',0,0.005);,',...
        'imshow(I)']);
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,',...
        'J=filter2(fspecial(''average'',3),I)/255;,',...
        'imshow(J)']);
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,',...
        'J=medfilt2(I,[3 3]);,',...
        'imshow(J)']);
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,',...
        'J=wiener2(I,[5 5]);,',...
        'imshow(J)']);
b4=uicontrol('parent',h0,...
    'units','points',...
    'tag','b4',...
    'style','pushbutton',...
    'string','关闭',...
    'fontsize',15,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[90 50 70 30],...
    'callback','close');
实例74:图像的区域处理

h0=figure('toolbar','none',...
    'position',[198 56 350 468],...
    'name','实例74');
h1=axes('parent',h0,...
    'position',[0.25 0.45 0.5 0.5],...
    'visible','off');
I=imread('trees.tif');
imshow(I)
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,',...
        'I=imread(''trees.tif'');,',...
        'imshow(I),',...
        'BW=roipoly;,',...
        'h=fspecial(''unsharp'');,',...
        'I2=roifilt2(h,I,BW);,',...
        'imshow(I2)']);
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,',...
        'BW=imread(''text.tif'');,',...
        'f=inline(''imadjust(x,[],[],0.01)'');,',...
        'I2=roifilt2(I,BW,f);,',...
        'imshow(I2)']);
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,',...
        'load trees,',...
        'I=ind2gray(X,map);,',...
        'imshow(I),',...
        'I2=roifill;,',...
        'imshow(I2)']);
b4=uicontrol('parent',h0,...
    'units','points',...
    'tag','b4',...
    'style','pushbutton',...
    'string','关闭',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[90 50 70 30],...
    'callback','close');
实例75:图像的颜色处置

h0=figure('toolbar','none',...
    'position',[198 56 350 468],...
    'name','实例75');
h1=axes('parent',h0,...
    'position',[0.12 0.45 0.75 0.5],...
    'visible','off');
I=imread('flowers.tif');
imshow(I)
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,',...
        '[X,map]=imread(''flowers.tif'');,',...
        '[Y,map2]=imapprox(X,map,64);,',...
        'image(Y),',...
        'colormap(map2)']);
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,',...
        'I=imread(''flowers.tif'');,',...
        '[X,map]=rgb2ind(I,128,''nodither'');,',...
        'imshow(X)']);
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,',...
        'I=imread(''flowers.tif'');,',...
        'Y=rgb2ntsc(I);,',...
        'J=Y(:,:,1);,',...
        'imshow(J)']);
b4=uicontrol('parent',h0,...
    'units','points',...
    'tag','b4',...
    'style','pushbutton',...
    'string','关闭',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[170 50 50 20],...
    'callback','close');
b5=uicontrol('parent',h0,...
    'units','points',...
    'tag','b5',...
    'style','pushbutton',...
    'string','颜色转换三',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[100 50 50 20],...
    'callback',[...
        'cla,',...
        'I=imread(''flowers.tif'');,',...
        'J=rgb2ycbcr(I);,',...
        'imshow(J)']);
b6=uicontrol('parent',h0,...
    'units','points',...
    'tag','b6',...
    'style','pushbutton',...
    'string','颜色转换二',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[30 50 50 20],...
    'callback',[...
        'cla,',...
        'I=imread(''flowers.tif'');,',...
        'J=rgb2hsv(I);,',...
        'imshow(J)']);
实例76:交换显示图像

h0=figure('toolbar','none',...
    'position',[198 56 500 500],...
    'name','实例76');
h1=axes('parent',h0,...
    'position',[0.15 0.5 0.7 0.5],...
    'visible','off');
u1=uimenu('parent',h0,...
    'label','加载图像',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'tag','u1',...
    'callback',[...
        '[X,map]=imread(''800.jpg'',''jpg'');,',...
        'Y=imresize(X,2);,',...
        'image(Y),',...
        'colormap(map),',...
        'axis image,',...
        'camva(camva/2.5),',...
        'disp(''单击鼠标左键点取需要的点''),',...
        'disp(''单击鼠标右键确定最后一个点''),',...
        'while 1,',...
        '[x,y]=ginput(1);,',...
        'if ~strcmp(get(gcf,''selectiontype''),''normal''),',...
        'break,',...
        'end,',...
        'ct=camtarget;,',...
        'dx=x-ct(1);,',...
        'dy=y-ct(2);,',...
        'camdolly(dx,dy,ct(3),''movetarget'',''data''),',...
        'drawnow,',...
        'end']);
u2=uimenu('parent',h0,...
    'label','关闭',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'tag','u2',...
    'callback','close');
实例77:矢量数据的显示

h0=figure('toolbar','none',...
    'position',[198 56 450 468],...
    'name','实例77');
h1=axes('parent',h0,...
    'position',[0.3 0.45 0.5 0.5],...
    'visible','off');
load wind
b1huidiao=[...
        'cla,',...
        'xmin = min(x(:));,',...
        'xmax = max(x(:));,',...
        'ymax = max(y(:));,',...
        'zmin = min(z(:));,',...
        'wind_speed = sqrt(u.^2 + v.^2 + w.^2);,',...
        'hsurfaces = slice(x,y,z,wind_speed,[xmin,100,xmax],ymax,zmin);,',...
        'set(hsurfaces,''FaceColor'',''interp'',''EdgeColor'',''none''),',...
        'hcont = contourslice(x,y,z,wind_speed,[xmin,100,xmax],ymax,zmin);,',...
        'set(hcont,''EdgeColor'',[.7,.7,.7],''LineWidth'',.5),',...
        '[sx,sy,sz] = meshgrid(80,20:10:50,0:5:15);,',...
        'hlines = streamline(x,y,z,y,v,w,sx,sy,sz);,',...
        'set(hlines,''LineWidth'',2,''Color'',''r''),',...
        'view(3),',...
        'daspect([2,2,1]),',...
        'axis tight'];
b2huidiao=[...
        'cla,',...
        'wind_speed = sqrt(u.^2 + v.^2 + w.^2);,',...
        'hiso = patch(isosurface(x,y,z,wind_speed,40));,',...
        'isonormals(x,y,z,wind_speed,hiso),',...
        'set(hiso,''FaceColor'',''red'',''EdgeColor'',''none'');,',...
        'hcap = patch(isocaps(x,y,z,wind_speed,40),''FaceColor'',''interp'',''EdgeColor'',''none'');,',...
        'colormap hsv,',...
        'daspect([1,1,1]);,',...
        '[f verts] = reducepatch(isosurface(x,y,z,wind_speed,30),0.07);,',...
        'h1 = coneplot(x,y,z,u,v,w,verts(:,1),verts(:,2),verts(:,3),3);,',...
        'set(h1,''FaceColor'',''blue'',''EdgeColor'',''none'');,',...
        'xrange = linspace(min(x(:)),max(x(:)),10);,',...
        'yrange = linspace(min(y(:)),max(y(:)),10);,',...
        'zrange = 3:4:15;,',...
        '[cx,cy,cz] = meshgrid(xrange,yrange,zrange);,',...
        'h2 = coneplot(x,y,z,u,v,w,cx,cy,cz,2);,',...
        'set(h2,''FaceColor'',''green'',''EdgeColor'',''none'');,',...
        'axis tight,',...
        'box on,',...
        'camproj perspective,',...
        'camzoom(1.25),',...
        'view(65,45),',...
        'camlight(-45,45),',...
        'lighting phong,',...
        'set(hcap,''AmbientStrength'',.6)'];
b1=uicontrol('parent',h0,...
    'style','pushbutton',...
    'units','points',...
    'tag','b1',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'string','可视化',...
    'position',[50 100 60 20],...
    'callback',b1huidiao);
b2=uicontrol('parent',h0,...
    'style','pushbutton',...
    'units','points',...
    'tag','b2',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'string','锥形图',...
    'position',[200 100 60 20],...
    'callback',b2huidiao);
b3=uicontrol('parent',h0,...
    'style','pushbutton',...
    'units','points',...
    'tag','b3',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'string','关闭',...
    'position',[125 60 60 20],...
    'callback','close'); 
实例78:图像分析(2)

h0=figure('toolbar','none',...
    'position',[198 56 350 468],... 
    'name','实例78');
h1=axes('parent',h0,...
    'position',[0.25 0.45 0.5 0.5],...
    'visible','off');
load imdemos flower
imshow(flower)
colormap(copper)
n=size(X,1);
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,',...
        '[X,map]=imread(''flowers.tif'');,',...
        'X=double(flower);,',...
        'X=(0.25/256)*X;,',...
        'C=copper(35);,',...
        'set(gca,''colororder'',C(21:35,:),''box'',''on'');,',...
        'imcontour(X,3);,',...
        'axis([1 n 1 n]),',...
        'axis(''ij''),',...
        'axis(''square'')']);
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,',...
        'D=-del2(X);,',...
        'pcolor(D),',...
        'axis([1 n 1 n]),',...
        'axis(''ij''),',...
        'shading(''flat'')']);
b3=uicontrol('parent',h0,...
    'units','points',...
    'tag','b3',...
    'style','pushbutton',...
    'string','3D表面图',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[170 100 50 20],...
    'callback',[...
        'cla,',...
        'D=-del2(X);,',...
        'surf(X,D),',...
        'colormap(copper),',...
        'axis([1 n 1 n 0 1]),',...
        'axis(''ij''),',...
        'shading(''flat''),',...
        'view(-20,75);']);
b4=uicontrol('parent',h0,...
    'units','points',...
    'tag','b4',...
    'style','pushbutton',...
    'string','关闭',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[80 50 80 30],...
    'callback','close'); 
实例79:图像逻辑操作

h0=figure('toolbar','none',...
    'position',[198 56 350 468],...
    'name','实例79');
h1=axes('parent',h0,...
    'position',[0.25 0.45 0.5 0.5],...
    'visible','off');
load imdemos bacteria
imshow(bacteria)
k1=~(bacteria>100);
k2=filter2(fspecial('laplacian'),bacteria);
k3=(k2>-4)&k1;
k4=erode(k1)&(k3==0);
[r,c]=find(k4);
k5=bwselect(k1,c,r);
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'string','二值分割图',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[30 110 50 20],...
    'callback',[...
        'cla,',...
        'imshow(k1)']);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'style','pushbutton',...
    'string','滤波结果图',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[100 110 50 20],...
    'callback',[...
        'cla,',...
        'imshow(k2)']);
b3=uicontrol('parent',h0,...
    'units','points',...
    'tag','b3',...
    'style','pushbutton',...
    'string','阈值化图',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[170 110 50 20],...
    'callback',[...
        'cla,',...
        'imshow(k3)']);
b4=uicontrol('parent',h0,...
    'units','points',...
    'tag','b4',...
    'style','pushbutton',...
    'string','目标的核',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[30 60 50 20],...
    'callback',[...
        'cla,',...
        'imshow(k4)']);
b5=uicontrol('parent',h0,...
    'units','points',...
    'tag','b5',...
    'style','pushbutton',...
    'string','目标分割图',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[100 60 50 20],...
    'callback',[...
        'cla,',...
        'imshow(k5)']);
b6=uicontrol('parent',h0,...
    'units','points',...
    'tag','b6',...
    'style','pushbutton',...
    'string','关闭',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[170 60 50 20],...
    'callback','close');
实例80:进度条的使用

h0=figure('toolbar','none',...
    'position',[198 56 350 450],...
    'name','实例80');
h1=axes('parent',h0,...
    'position',[0.25 0.45 0.6 0.5],...
    'visible','off');

I=imread('flowers.tif');
imshow(I)
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'string','转换',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[50 80 60 25],...
    'callback',[...
        'handlek=waitbar(0,''initializing......'');,',...
        'pause(0.5),',...
        'i=1;,',...
        'while  i<=100,',...
        'waitbar(i/100,handlek,[num2str(i),''%finished''],handlek),',...
        'i=i+1;,',...
        'pause(0.05),',...
        'end,',...
        'pause(1.5),',...
        'cla,',...
        'delete(handlek),',...
        'Y=rgb2ntsc(I);,',...
        'J=Y(:,:,1);,',...
        'imshow(J)']);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'style','pushbutton',...
    'string','关闭',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[150 80 60 25],...
    'callback','close');
例81:MRI数据的显示

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'); 
实例82:图像类型转换

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'); 
实例83:特殊的图像显示技术

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)']);
实例84:图像的几何操作

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]);
实例85:拉个朗日插值

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');
例86:三次样条插值法

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');
实例87:NEWTON插值

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','节点数:(<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');
实例88:hermite插值

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');
实例89:mewton形式的hermite插值

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');
实例90:平方根法

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');
实例91:gauss消去法

h0=figure('toolbar','none',...
    'position',[200 150 450 250],...
    'name','实例91');
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 2 4 1 7;2 3 0 1 8;4 1 7 6 1;1 1 0 2 1;1 3 0 1 1;];,',...
        'b=[15 14 19 5 6]'';,',...
        'r=[a,b];,',...
        'n=5;,',...
        'tic,',...
        'x=gauss(r,n);,',...
        'time1=toc;,',...
        'T=num2str(time1);,',...
        'set(e1,''string'',[T,''秒'']);,',...
        'msgbox([''X=['',num2str(x(1)),num2str(x(2)),num2str(x(3)),num2str(x(4)),num2str(x(5)),'']''],''方程组的解'');'];
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','GS消去法',...
    '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');
实例92:三角分解法

h0=figure('toolbar','none',...
    'position',[200 150 450 250],...
    'name','实例92');
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 2 4 1 7;2 3 0 1 8;4 1 7 6 1;1 1 0 2 1;1 3 0 1 1;];,',...
        'b=[15 14 19 5 6]'';,',...
        'n=5;,',...
        'tic,',...
        'x=dirang(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)),num2str(x(5)),'']''],''方程组的解'');'];
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',[270 100 50 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');
实例93:jacobi迭代法

h0=figure('toolbar','none',...
    'position',[200 150 450 250],...
    'name','实例93');
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]'';,',...
        'n=4;,',...
        'u=zeros(n,1);,',...
        'tic,',...
        '[x,k]=jac(a,b,n,u);,',...
        'time1=toc;,',...
        'T=num2str(time1);,',...
        'set(e1,''string'',[T,''秒'']);,',...
        'set(e2,''string'',num2str(k));,',...
        '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',[295 130 35 20]);
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','计算时间:',...
    'fontsize',10,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[240 130 50 20]);
e2=uicontrol('parent',h0,...
    'units','points',...
    'tag','e2',...
    'style','edit',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[295 100 35 20]);
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','迭代步数:',...
    'fontsize',10,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[240 100 50 20]);
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'string','Jacobi 迭代法',...
    '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');
实例94:gauss迭代法

h0=figure('toolbar','none',...
    'position',[200 150 450 250],...
    'name','实例94');
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]'';,',...
        'n=4;,',...
        'u=zeros(n,1);,',...
        'tic,',...
        '[x,k]=gs(a,b,n,u);,',...
        'time1=toc;,',...
        'T=num2str(time1);,',...
        'set(e1,''string'',[T,''秒'']);,',...
        'set(e2,''string'',num2str(k));,',...
        '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',[295 130 35 20]);
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','计算时间:',...
    'fontsize',10,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[240 130 50 20]);
e2=uicontrol('parent',h0,...
    'units','points',...
    'tag','e2',...
    'style','edit',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[295 100 35 20]);
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','迭代步数:',...
    'fontsize',10,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[240 100 50 20]);
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'string','GS 迭代法',...
    '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');
实例95:sor迭代法

h0=figure('toolbar','none',...
    'position',[200 150 450 250],...
    'name','实例95');
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]'';,',...
        'n=4;,',...
        'u=zeros(n,1);,',...
        'tic,',...
        '[x,k]=sor(a,b,n,u);,',...
        'time1=toc;,',...
        'T=num2str(time1);,',...
        'set(e1,''string'',[T,''秒'']);,',...
        'set(e2,''string'',num2str(k));,',...
        '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',[295 130 35 20]);
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','计算时间:',...
    'fontsize',10,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[240 130 50 20]);
e2=uicontrol('parent',h0,...
    'units','points',...
    'tag','e2',...
    'style','edit',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[295 100 35 20]);
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','迭代步数:',...
    'fontsize',10,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[240 100 50 20]);
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'string','SOR 迭代法',...
    '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');
实例96:最速下降法

h0=figure('toolbar','none',...
    'position',[200 150 450 250],...
    'name','实例96');
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]'';,',...
        'n=4;,',...
        'u=zeros(n,1);,',...
        'tic,',...
        '[x,k]=cg(a,b,n,u);,',...
        'time1=toc;,',...
        'T=num2str(time1);,',...
        'set(e1,''string'',[T,''秒'']);,',...
        'set(e2,''string'',num2str(k));,',...
        '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',[295 130 35 20]);
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','计算时间:',...
    'fontsize',10,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[240 130 50 20]);
e2=uicontrol('parent',h0,...
    'units','points',...
    'tag','e2',...
    'style','edit',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[295 100 35 20]);
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','迭代步数:',...
    'fontsize',10,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[240 100 50 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');
实例97:共额梯度法

h0=figure('toolbar','none',...
    'position',[200 150 450 250],...
    'name','实例97');
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]'';,',...
        'n=4;,',...
        'u=zeros(n,1);,',...
        'tic,',...
        '[x,k]=getd(a,b,n,u);,',...
        'time1=toc;,',...
        'T=num2str(time1);,',...
        'set(e1,''string'',[T,''秒'']);,',...
        'set(e2,''string'',num2str(k));,',...
        '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',[295 130 35 20]);
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','计算时间:',...
    'fontsize',10,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[240 130 50 20]);
e2=uicontrol('parent',h0,...
    'units','points',...
    'tag','e2',...
    'style','edit',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[295 100 35 20]);
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','迭代步数:',...
    'fontsize',10,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[240 100 50 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');
实例98:mewton迭代法

h0=figure('toolbar','none',...
    'position',[200 150 450 250],...
    'name','实例98');
h1=axes('parent',h0,...
    'position',[0.05 0.15 0.65 0.6],...
    'visible','off');
I=imread('fabmatrix.bmp','bmp');
image(I)
axis off
huidiao=[...
        'n=3;,',...
        'u=zeros(n,1);,',...
        'tic,',...
        '[x,k]=nnewton(u,n);,',...
        'time1=toc;,',...
        'T=num2str(time1);,',...
        'set(e1,''string'',[T,''秒'']);,',...
        'set(e2,''string'',num2str(k));,',...
        'msgbox([''X=['',num2str(x(1)),'' '',num2str(x(2)),'' '',num2str(x(3)),'']''],''方程组的解'');'];
t1=uicontrol('parent',h0,...
    'units','points',...
    'tag','t1',...
    'style','text',...
    'string','非线性方程组如下:',...
    'fontsize',15,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[20 150 150 20]);
e1=uicontrol('parent',h0,...
    'units','points',...
    'tag','e1',...
    'style','edit',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[295 130 35 20]);
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','计算时间:',...
    'fontsize',10,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[240 130 50 20]);
e2=uicontrol('parent',h0,...
    'units','points',...
    'tag','e2',...
    'style','edit',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[295 100 35 20]);
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','迭代步数:',...
    'fontsize',10,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[240 100 50 20]);
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'string','Newton 迭代法',...
    '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');
实例99:broyden迭代法

h0=figure('toolbar','none',...
    'position',[200 150 450 250],...
    'name','实例99');
h1=axes('parent',h0,...
    'position',[0.05 0.15 0.65 0.6],...
    'visible','off');
I=imread('fabmatrix.bmp','bmp');
image(I)
axis off
huidiao=[...
        'n=3;,',...
        'u=zeros(n,1);,',...
        'tic,',...
        '[x,k]=broyden(u,n);,',...
        'time1=toc;,',...
        'T=num2str(time1);,',...
        'set(e1,''string'',[T,''秒'']);,',...
        'set(e2,''string'',num2str(k));,',...
        'msgbox([''X=['',num2str(x(1)),'' '',num2str(x(2)),'' '',num2str(x(3)),'']''],''方程组的解'');'];
t1=uicontrol('parent',h0,...
    'units','points',...
    'tag','t1',...
    'style','text',...
    'string','非线性方程组如下:',...
    'fontsize',15,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[20 150 150 20]);
e1=uicontrol('parent',h0,...
    'units','points',...
    'tag','e1',...
    'style','edit',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[295 130 35 20]);
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','计算时间:',...
    'fontsize',10,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[240 130 50 20]);
e2=uicontrol('parent',h0,...
    'units','points',...
    'tag','e2',...
    'style','edit',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[295 100 35 20]);
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','迭代步数:',...
    'fontsize',10,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[240 100 50 20]);
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'string','Broyden 迭代法',...
    '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');
实例100:逆broyden迭代法

h0=figure('toolbar','none',...
    'position',[200 150 450 250],...
    'name','实例100');
h1=axes('parent',h0,...
    'position',[0.05 0.15 0.65 0.6],...
    'visible','off');
I=imread('fabmatrix.bmp','bmp');
image(I)
axis off
huidiao=[...
        'n=3;,',...
        'u=zeros(n,1);,',...
        'tic,',...
        '[x,k]=fbroyden(u,n);,',...
        'time1=toc;,',...
        'T=num2str(time1);,',...
        'set(e1,''string'',[T,''秒'']);,',...
        'set(e2,''string'',num2str(k));,',...
        'msgbox([''X=['',num2str(x(1)),'' '',num2str(x(2)),'' '',num2str(x(3)),'']''],''方程组的解'');'];
t1=uicontrol('parent',h0,...
    'units','points',...
    'tag','t1',...
    'style','text',...
    'string','非线性方程组如下:',...
    'fontsize',15,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[20 150 150 20]);
e1=uicontrol('parent',h0,...
    'units','points',...
    'tag','e1',...
    'style','edit',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[295 130 35 20]);
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','计算时间:',...
    'fontsize',10,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[240 130 50 20]);
e2=uicontrol('parent',h0,...
    'units','points',...
    'tag','e2',...
    'style','edit',...
    'horizontalalignment','right',...
    'backgroundcolor',[1 1 1],...
    'position',[295 100 35 20]);
t2=uicontrol('parent',h0,...
    'units','points',...
    'tag','t2',...
    'style','text',...
    'string','迭代步数:',...
    'fontsize',10,...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[240 100 50 20]);
b1=uicontrol('parent',h0,...
    'units','points',...
    'tag','b1',...
    'style','pushbutton',...
    'string','逆Broyden 迭代法',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[250 60 70 20],...
    'callback',huidiao);
b2=uicontrol('parent',h0,...
    'units','points',...
    'tag','b2',...
    'string','关闭',...
    'style','pushbutton',...
    'backgroundcolor',[0.75 0.75 0.75],...
    'position',[250 30 70 20],...
    'callback','close');
XOR

function [x,st]=sor(a,b,n,x1)
D=zeros(n,n);
L=zeros(n,n);
U=zeros(n,n);
for i=1:n
    for j=1:n
        if j==i
            D(i,j)=a(i,j);
        end
        if j<i
            L(i,j)=-a(i,j);
        end
        if j>i
            U(i,j)=-a(i,j);
        end
    end
end
opt=oumiga(a);
Bsor=inv(D-opt*L)*[(1-opt)*D+opt*U];
fsor=opt*inv(D-opt*L)*b;
k=1;
x2=Bsor*x1+fsor;
e=x2-x1;
while norm(e,2)>1e-6
    k=k+1;
    x1=x2;
    x2=Bsor*x1+fsor;
    e=x2-x1;
end
x=x2;
st=k;