?? matlab實(shí)用程序百例3.txt
字號(hào):
'dn=str2num(strdn);,',...
'dd=abs(sin(dn)-nhermite(dn,n1,n2));,',...
'msgbox([''誤差為:'',num2str(dd)],''計(jì)算結(jié)果'')']);
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','誤差點(diǎn):',...
'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','第一節(jié)點(diǎn):',...
'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','第二節(jié)點(diǎn):',...
'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','關(guān)閉',...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[100 20 60 20],...
'callback','close');
實(shí)例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','計(jì)算時(shí)間:',...
'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','關(guān)閉',...
'style','pushbutton',...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[250 30 60 20],...
'callback','close');
實(shí)例91:gauss消去法
h0=figure('toolbar','none',...
'position',[200 150 450 250],...
'name','實(shí)例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','計(jì)算時(shí)間:',...
'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','關(guān)閉',...
'style','pushbutton',...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[250 30 60 20],...
'callback','close');
實(shí)例92:三角分解法
h0=figure('toolbar','none',...
'position',[200 150 450 250],...
'name','實(shí)例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','計(jì)算時(shí)間:',...
'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','關(guān)閉',...
'style','pushbutton',...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[250 30 60 20],...
'callback','close');
實(shí)例93:jacobi迭代法
h0=figure('toolbar','none',...
'position',[200 150 450 250],...
'name','實(shí)例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','計(jì)算時(shí)間:',...
'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','迭代步數(shù):',...
'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','關(guān)閉',...
'style','pushbutton',...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[250 30 60 20],...
'callback','close');
實(shí)例94:gauss迭代法
h0=figure('toolbar','none',...
'position',[200 150 450 250],...
'name','實(shí)例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','計(jì)算時(shí)間:',...
'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','迭代步數(shù):',...
'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','關(guān)閉',...
'style','pushbutton',...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[250 30 60 20],...
'callback','close');
實(shí)例95:sor迭代法
h0=figure('toolbar','none',...
'position',[200 150 450 250],...
'name','實(shí)例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',...
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -