如何利用误差实现迭代?
我有下面的程序,想以x与x0的差值作为控制迭代次数的量。假设迭代后x的差值不大于0.5。请问如何实现?
x0 = ;
hk0 = 3614/2.47;
hk1 = hk0*(cos(42.5/180*pi))^2;
e1 = 0.5*hk1*2.47^2*2;
K=;
M=1000*;
e2 = 0.5*x0*K*(x0)';
es = e1+e2;
ed = 1.78+(2.9-1.78)*(x0(1)-2.41)/(3.24-2.41);
kesieq = ed/(4*pi*es);
kesi = kesieq+0.05;
ita = 1+(0.05-kesi)/(0.06+1.7*kesi);
K(1,1)=K(1,1)+hk1;
omiga=sqrt(min(abs(eig(inv(M)*K))));
T=2*pi/omiga;
Fek=ita*1.4*9340;
F1=768.3/(768.3+329.4)*Fek;
F2=Fek-F1;
x=inv(K)* clear all
x = ;
x0 = ;
n=0
while (x(1)-x0(1))/x0(1) > 0.05
x0=x;
n=n+1;
hk0 = 3292.8/2.47;
hk1 = hk0*(cos(42.5/180*pi))^2;
e1 = 0.5*hk1*2.47^2*2;
K=;
M=1000*;
e2 = 0.5*x0*K*(x0)';
es = e1+e2;
ed = 1.78+(2.9-1.78)*(x0(1)-2.41)/(3.24-2.41);
kesieq = ed/(4*pi*es);
kesi = kesieq+0.05;
ita = 1+(0.05-kesi)/(0.06+1.7*kesi);
K(1,1)=K(1,1)+hk1;
omiga=sqrt(min(abs(eig(inv(M)*K))));
T=2*pi/omiga;
Fek=ita*1.4*9340;
F1=768.3/(768.3+329.4)*Fek;
F2=Fek-F1;
xd=inv(K)*;
x=xd';
end
x
这样好像解决了。
页:
[1]