马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
根据LET工具箱的代码,降le指数正交化的方法进行了改进,以duffing系统为例,和LET的结果对比了一下,看看那个结果更精确
主程序如下:
% 计算duffing吸引子的Lyapunov指数
clear all;
clc;
% 初始化输入
yinit = [1,1,1];
orthmatrix = [1 0 0;
0 1 0;
0 0 1];
y = zeros(12,1);
IC(1:3) = yinit;
IC(4:12) = orthmatrix;
InitialTime = 0; % 时间初始值
TimeStep = 1e-2; % 时间步长
wholetimes = 1e5; % 总的循环时间
UpdateStepNum = 10; % 每次演化的步数
iteratetimes = wholetimes/UpdateStepNum; % 演化的次数
DiscardItr=200; %抛弃的不稳定迭代次数
Iteration=UpdateStepNum*TimeStep;
DiscardTime=DiscardItr*Iteration+InitialTime;
mod = zeros(1,3);
d=3; %维数
Sum=zeros(1,d);
n=0; %总的迭代计数
k=0; %对结果有作用的迭代计数
xData=[];
yData=[];
T1=InitialTime;
T2=T1+Iteration;
TSpan=[T1:TimeStep:T2];
options=odeset('RelTol',1e-5,'AbsTol',1e-6);
for i=1:iteratetimes
n=n+1;
[t,X] =ode45('duffingfun', TSpan, IC,options);
[rX,cX]=size(X);
L=cX-d*d;
% 取积分得到的最后一个时刻的值
for i=1:d
m1=L+1+(i-1)*d;
m2=m1+d-1;
A(:,i)=(X(rX,m1:m2))';
end
y0 = ThreeGS(A); %正交化
% 取三个向量的模
mod(1) = sqrt(y0(:,1)'*y0(:,1));
mod(2) = sqrt(y0(:,2)'*y0(:,2));
mod(3) = sqrt(y0(:,3)'*y0(:,3));
y0(:,1) = y0(:,1)/mod(1);
y0(:,2) = y0(:,2)/mod(2);
y0(:,3) = y0(:,3)/mod(3);
if T2>DiscardTime
Q0=y0;
else
Q0=eye(d);
end
if (T2>DiscardTime )
k=k+1;
T=k*Iteration;
TT=n*Iteration+InitialTime;
%计算lyapunov指数
Sum=Sum+log(abs(mod));
lambda=Sum/T;
%按降序排列指数
Lambda=fliplr(sort(lambda));
xData=[xData;TT];
yData=[yData;lambda];
end
% 重新定义起始时刻
ic=X(rX,1:L);
T1=T1+Iteration;
T2=T2+Iteration;
TSpan=[T1:TimeStep:T2];
IC=[ic(:);y0(:)];
end
plot(xData,yData(:,1),xData,yData(:,2),xData,yData(:,3))
function dX = duffingfun(t,X)
k=0.1;
B=11;
x=X(1); y=X(2);z=X(3);
Y=[X(4),X(7),X(10);
X(5),X(8),X(11);
X(6),X(9),X(12)];
dX = zeros(12,1);
dX(1)=y;
dX(2)=-k*y-x^3+B*cos(z);
dX(3)=1;
J=[ 0, 1, 0;
-3*x^2, -k, -B*sin(z);
0, 0, 0];
dX(4:12) = J*Y;
function A = ThreeGS(V)
v1 = V(:,1);
v2 = V(:,2);
v3 = V(:,3);
a1 = zeros(3,1);
a2 = zeros(3,1);
a3 = zeros(3,1);
a1 = v1;
a2 = v2-((a1'*v2)/(a1'*a1))*a1;
a3 = v3-((a1'*v3)/(a1'*a1))*a1-((a2'*v3)/(a2'*a2))*a2;
A = [a1,a2,a3]; |