📄 新建 文本文档.txt
字号:
逆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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -