|
楼主,用wolf法计算lyapunov指数哪个程序是不是没有主函数,我这段时间做duffing方程的lyapunov指数,用matlab编了一个程序,可是运行出来的结果不对,能不能帮我看一下,错误出在那?
function []=lyapu()
N=2;
d0=0.0001;
x=[0,0];
d=0;
sum=0;
dt=0.01;
for i=1:N
z(i)=x(i)+d0;
end
d0=distance(x,z);
lnd0=log(d0);
p=0;
q=p+dt;
F=0.15;
options=odeset('AbsTol',1e-6,'RelTol',1e-3);
while F<=0.25
for i=1:N
x(i)=x(i);
z(i)=x(i)+d0;
end
for ii=1:20000
tspan=[p,q];
[t,x]=ode45(@duffing,tspan,x,options,F);
[t,z]=ode45(@duffing,tspan,z,options,F);
[m,n]=size(x);
x=x(m,:);
[h,s]=size(z);
z=z(h,:);
d=distance(x,z);
sum=sum+log(d)-lnd0;
for i=1:N
x(i)=x(i);
z(i)=x(i)+d0*(z(i)-x(i))/d;
end
end
p=p+dt;
q=q+dt;
ly=sum/ii;
ly=(ly)/dt;
figure(1);
hold on
plot(F,ly);
F=F+0.01;
% hold off
end
function [dist]=distance(p,h)
dist=0;
for i=1:2
D=h(i)-p(i);
D=D*D;
dist=dist+D;
end
dist=sqrt(dist);
function [dx]=duffing(t,x,F)
% global F;
w0=1.0;
gama=0.168;
dx=[x(2);F*sin(w0*t)-gama*x(2)+1/2*x(1)*(1-x(1)^2)]; |
|