|
这个程序是一个博客上面的,我在这里引用一下!没有和作者沟通,吧程序贴上,希望原作者见谅!
Z=[];
d0=1e-8;
for a=linspace(32,40,80)
lsum=0;
x=1;y=1;z=1;
x1=1;y1=1;z1=1+d0;
for i=1:1000
[T1,Y1]=ode45('Chen',1,[x;y;z;a;3;28]);
[T2,Y2]=ode45('Chen',1,[x1;y1;z1;a;3;28]);
n1=length(Y1);n2=length(Y2);
x=Y1(n1,1);y=Y1(n1,2);z=Y1(n1,3);
x1=Y2(n2,1);y1=Y2(n2,2);z1=Y2(n2,3);
d1=sqrt((x-x1)^2+(y-y1)^2+(z-z1)^2);
x1=x+(d0/d1)*(x1-x);
y1=y+(d0/d1)*(y1-y);
z1=z+(d0/d1)*(z1-z);
if i>500
lsum=lsum+log(d1/d0);
end
end
Z=[Z lsum/(i-500)];
end
a=linspace(32,40,80);
plot(a,Z,'-');
title('Chen 系统最大lyapunov指数')
xlabel('parameter a'),ylabel('lyapunov exponents')
Z=[];
d0=1e-8;
for a=linspace(32,40,80)
lsum=0;
x=1;y=1;z=1;
x1=1;y1=1;z1=1+d0;
for i=1:10000
[T1,Y1]=ode45('Chen',1,[x;y;z;a;3;28]);
[T2,Y2]=ode45('Chen',1,[x1;y1;z1;a;3;28]);
n1=length(Y1);n2=length(Y2);
x=Y1(n1,1);y=Y1(n1,2);z=Y1(n1,3);
x1=Y2(n2,1);y1=Y2(n2,2);z1=Y2(n2,3);
d1=sqrt((x-x1)^2+(y-y1)^2+(z-z1)^2);
x1=x+(d0/d1)*(x1-x);
y1=y+(d0/d1)*(y1-y);
z1=z+(d0/d1)*(z1-z);
if i>5000
lsum=lsum+log(d1/d0);
end
end
Z=[Z lsum/(i-5000)];
end
a=linspace(32,40,80);
plot(a,Z,'-');
title('Chen 系统最大lyapunov指数')
xlabel('parameter a'),ylabel('lyapunov exponents') |
|