|
楼主 |
发表于 2011-7-11 20:25
|
显示全部楼层
调整后的程序,但结果不理想,望指点
function [lambda,LE]=lyapunov(delt_t,Y,h,a,R,bata)
% lambda=lyapunov(0.01,Y,100,2,20);
% load('Y.mat');
% delt_t=0.01;
% a=2;h=100;R=10;
% bata=40;
M=length(Y); %Y的第1列是横坐标,第2列是纵坐标
date_N1=a/delt_t; %限制不是同一条轨迹
date_N2=R/delt_t; %限制不是离的很远的轨迹,减少计算量
for i=1:M-h
num=0;
for j=1:M-h
if (abs(j-i)>date_N1)&(abs(j-i)<date_N2) %寻找相空间中每个点的最近距离点,并记下该点下标
num=num+1;
index(num)=j;
d_s(num)=((Y(j,1)-Y(i,1))^2+(Y(j,2)-Y(i,2))^2)^0.5; % 求最短距离
else
continue
end
end
[d_s,ind]=sort(d_s); %求最近的临近点
turn=1;
for k=1:h
% turn=1;
jj=index(ind(turn));
d1=((Y(i,:)-Y(jj,:))*(Y(i,:)-Y(jj,:))')^0.5;
d2=((Y(i+turn,:)-Y(jj+turn,:))*(Y(i+turn,:)-Y(jj+turn,:))')^0.5;
cosine=(Y(jj,:)-Y(i,:))*(Y(jj+turn,:)-Y(i+turn,:))'/(d1*d2); %求夹角
ind1=0;
if acos(cosine)<bata*pi/180 %限制夹角小于bata
ind1=ind1+1;
D1(ind1)=((Y(i,:)-Y(jj,:))*(Y(i,:)-Y(jj,:))')^0.5;
D2(ind1)=((Y(i+k,:)-Y(jj+k,:))*(Y(i+k,:)-Y(jj+k,:))')^0.5;
lambda1(ind1)=log(D2(ind1)/D1(ind1))/(k*delt_t);
else
turn=turn+1;
continue
end
end
lambda(i)=max(lambda1);
% lambda(i)=mean(lambda1);
end
LE=mean(lambda); |
|