|
楼主 |
发表于 2007-10-7 22:03
|
显示全部楼层
程序
clear all
a=0.0;
b=40;
u0=0;
o0=0;
x0=0;
y0=0;
m=1000;
h=(b-a)/m;
T=zeros(1,m+1);
%z=zeros(m+1,length(za));
f=zeros(1,4);
g=zeros(1,4);
p=zeros(1,4);
q=zeros(1,4);
T=a:h:b;
u(1)=u0;
o(1)=o0;
x(1)=x0;
y(1)=y0;
for j=1:m
f1=x(j);
g1=y(j);
p1=2.028*sin(pi*T(j)/2)-42.67*x(j)+74.43*y(j)-17720.89*u(j)+34223*o(j);
q1=0.3405*sin(pi*T(j)/2)-0.016*x(j)-59.66*y(j)-7.45*u(j)-25859*o(j);
f2=(x(j)+h*f1/2);
g2=(y(j)+h*g1/2);
p2=2.028*sin((pi*T(j)+h/2)/2)-42.67*(x(j)+h*f1/2)+74.43*(y(j)+h*g1/2)-17720.89*(u(j)+h*p1/2)+34223*(o(j)+h*q1/2);
q2=0.3405*sin((pi*T(j)+h/2)/2)-0.016*(x(j)+h*f1/2)-59.66*(y(j)+h*g1/2)-7.45*(u(j)+h*p1/2)-25859*(o(j)+h*q1/2);
f3=(x(j)+h*f2/2);
g3=(y(j)+h*g2/2);
p3=2.028*sin((pi*T(j)+h/2)/2)-42.67*(x(j)+h*f2/2)+74.43*(y(j)+h*g2/2)-17720.89*(u(j)+h*p2/2)+34223*(o(j)+h*q2/2);
q3=0.3405*sin((pi*T(j)+h/2)/2)-0.016*(x(j)+h*f2/2)-59.66*(y(j)+h*g2/2)-7.45*(u(j)+h*p2/2)-25859*(o(j)+h*q2/2);
f4=(x(j)+h*f3);
g4=(x(j)+h*g3);
p4=2.028*sin((pi*T(j)+h)/2)-42.67*(x(j)+h*f3)+74.43*(y(j)+h*g3)-17720.89*(u(j)+h*p3)+34223*(o(j)+h*q3);
q4=0.3405*sin((pi*T(j)+h)/2)-0.016*(x(j)+h*f3)-59.66*(y(j)+h*g3)-7.45*(u(j)+h*p3)-25859*(o(j)+h*q3);
u(j+1)=u(j)+(f1+2*f2+2*f3+f4)*h/6;
o(j+1)=o(j)+(g1+2*g2+2*g3+g4)*h/6;
x(j+1)=x(j)+(p1+2*p2+2*p3+p4)*h/6;
y(j+1)=y(j)+(q1+2*q2+2*q3+q4)*h/6;
end
r=[T',u',o',x',y']
程序写出了,但是老是结果不对,请高手看看毛病在哪。 |
|