这是我编的计算关联维的一部分程序,大家帮我看看有没有问题。
xa=c;%取时间6e-006-0.03的5000个数据
figure(1);
t1=1:5000;
plot(xa)
xlabel('t1');
ylabel('xa');
title('xa的分布');
n=100;
for t=1:50
xxa(t,:)=xa(100*t-99:100*t,1);%将数据分为50组,每组100个数据
end
d=7; %嵌入维d
for t=1:100+1-d
for dd=1:d
xxa1(t,dd)=xxa(1,t+dd-1); %将第一组数据进行d维重构空间X
end
end
N=100+1-d;
for i=1:N-1
for j=i+1:N
obja1(i,j-1)=norm(xxa1(i,:)-xxa1(j,:));
end
end
sa1=max(obja1);ssa1=min(obja1);
r=0.2:0.002:0.384;
for e=1:N-1
for i=1:N-1
for j=i+1:N
if r(e)-obja1(i,j-1)>=0
Heaviside(i,j-1)=1;
else
Heaviside(i,j-1)=0;
end
end
end
Ca1(e)=(2/(N*(N-1)))*sum(sum(Heaviside));%求出关联积分
end
%画出lnC/lnr的图
figure(2);
plot(log(r),log(Ca1));
xlabel('lnr');
ylabel('lnCd(r)');
%%%用滑动五点回归法求局部斜率%%%
r=0.2:0.002:0.384; s=5;
for t=1:89
for ss=1:s
rr(t,ss)=r(t+ss-1);
end
end
X=log(rr);
for t=1:89
for ss=1:s
CCa1(t,ss)=Ca1(t+ss-1);
end
end
Ya1=log(CCa1);
for t=1:89
a1(t)=inv(X(t,:)*(X(t,:))')*(X(t,:)*(Ya1(t,:))');
end
r=0.2:0.002:0.376;
figure(3);
plot(log(r),a1,'k');
grid on
xlabel('lnr');
ylabel('局部斜率');
%%%用最小二乘求关联维数%%%
n=28;
for f=62:89
ma1(f)=log(r(f));
Ma1(f)=log(Ca1(f));
mma1=(1/n)*sum(ma1);
MMa1=(1/n)*sum(Ma1);
mmma1(f)=ma1(f)-mma1;
MMMa1(f)=Ma1(f)-MMa1;
Da1(f)=sum(sum((ma1(f)-mma1)*(Ma1(f)-MMa1)))/sum(sum((ma1(f)-mma1)^2));
end
DDa1=Da1'; |