马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
w=[4:0.2:8];
Hlw=1/sqrt(8);
m=1;
c=0.1;
k=1;
r=5;
a=0.3;
a1=1;
a3=1;
error1=1;
error3=1;
ux1=0;%上面是赋的各项初值
while error1>0.001|error3>0.001
for i=1:21
Hw(i)=1/(-w(i)^2*m+sqrt(-1)*w(i)*c+k+a1);%H(w)
Hx1(i)=Hlw*Hw(i);%一次传递函数
Chx1(i)=conj(Hx1(i));%w为负时一次传递函数
end
for i=1:21
for j=1:21
Hfw(i,j)=-a3*Hx1(i)*Hx1(j);%Hf(w1,w2)
Hfw1(i,j)=-a3*(1/(-w(i)^2*m-sqrt(-1)*w(i)*c+k+a1))*Hx1(j);%正负
CHfw(i,j)=conj(Hfw(i,j));%2负
Hx2(i,j)=1/(-(w(i)+w(j))^2*m+sqrt(-1)*(w(i)+w(j))*c+k+a1)*Hfw(i,j);%二次传递函数
Hx21(i,j)=1/(-(w(i)+w(j))^2*m+sqrt(-1)*(w(i)+w(j))*c+k+a1)*Hfw1(i,j);%一正一负
Hx22(i,j)=1/(-(w(i)+w(j))^2*m+sqrt(-1)*(w(i)+w(j))*c+k+a1)*CHfw(i,j);%全为负
end
end
ux21=0;
ux22=0;
ux31=0;
ux32=0;
for i=1:21
ux21=ux21+2*(abs(Hx1(i)))^2*0.2;
for j=1:21
ux22=ux22+2*(abs(Hx2(i,j)))^2*0.04+4*(abs(Hx21(i,j)))^2*0.04+2*(abs(Hx22(i,j)))^2*0.04;
ux31=ux31+6*conj(Hx1(i))*conj(Hx1(j))*Hx2(i,j)*0.04+12*Hx1(i)*conj(Hx1(j))*Hx21(i,j)*0.04+6*Hx1(i)*Hx1(j)*Hx22(i,j)*0.04;
for k=1:21
ux32=ux32+8*conj(Hx2(i,j))*Hx21(i,k)*Hx2(j,k)*0.008+8*conj(Hx2(i,j))*Hx2(i,k)*Hx21(j,k)*0.008+8*conj(Hx21(i,j))*Hx21(i,k)*Hx21(j,k)*0.008+8*conj(Hx21(i,j))*Hx2(i,k)*Hx22(j,k)*0.008+8*conj(Hx21(i,j))*Hx22(i,k)*Hx2(j,k)*0.008+8*conj(Hx22(i,j))*Hx21(i,k)*Hx21(j,k)*0.008+8*conj(Hx21(i,j))*Hx21(i,k)*Hx21(j,k)*0.008+8*conj(Hx22(i,j))*Hx21(i,k)*Hx22(j,k)*0.008;
end
end
end
ux2=ux21+ux22;
ux22=sqrt(ux2);
ux3=ux31+ux32;
a1=(a-ux1)/sqrt(ux2);
q1=erf(real(a1/sqrt(2)));
q2=1/sqrt(2*pi)*exp(-1/2*a1^2);
I0=2*r*ux2*((a1^2+1)*q1+a1*q2)
I1=4*r*ux2^(3/2)*(a1*q1+q2);
I2=2*r*ux2^2*((a1^2+3)*q1+a1*q2);
I3=4*ux2^(5/2)*(3*a1*q1+4*q2)
I4=2*r*(ux2)^3*(3*(a1^2+5)*q1+a1*q2);
I5=4*r*(ux2)^(7/2)*(15*a1*q1+(a1^2+24)*q2);
E0=I0-1/2*ux3/ux2^2*I1+1/6*ux3/ux2^3*I3
E1=I1-1/2*ux3/ux2^2*I2+1/6*ux3/ux2^3*I4;
E2=I2-1/2*ux3/ux2^2*I3+1/6*ux3/ux2^3*I5;
a31=(E1*ux3-E2*ux2+E0*ux2^2)/(ux3^2-2*ux2^3);
error3=abs(double(a31-a3));
a3=a31;
a11=(E1-((E1*ux3-E2*ux2+E0*ux2^2)/(ux3^2-2*ux2^3))*ux3)/ux2;
error2=abs(double(a11-a1));
a1=a11;
ux1=0.1-E0;
end
我直接把程序贴上了,我运行的时候老是出现死循环,数值越来越大。不知道哪个地方出现了问题!希望编程高手不吝赐教!谢谢
[ 本帖最后由 eight 于 2008-1-9 10:39 编辑 ] |