CC算法出现的问题
data=b(:,1);N=length(data);max_d=10;%the maximum value of the time delay
sigma=std(data);%calcute standard deviation s_d
for t=1:max_d
s_t=0;
delt_s_s=0;
for m=2:5
s_t1=0;
for j=1:4
r=sigma*j/2;
for i=1:t
for j=1:N/t
data_d(i,j)=data(i+(j-1)*t);
end
end
=size(data_d);
s_t3=0;
for i=1:t
Y=data_d(i,:);
sum_H=0;
for ii=1:N/t-1
for jj=i+1:N/t
d=max(abs(Y(:,ii)-Y(:,jj)));%计算相空间中每两点之间的距离,
if r>d
%sita=heaviside(r,d);%计算Heaviside 函数之值n
sum_H=sum_H+1;
end
end
end
C_1(i)=2*sum_H/(N/t*(N/t-1));
N_r=N/t-(m-1); %相空间中点的个数
Data=zeros(m, N_r);
for j=1:N_r
for i=1:m %相空间重构
Data(i,j)=data((i-1)*t+j);
end
end
sum=0;
for ii=1:N_r-1
for jj=i+1:N_r
d=norm((Data(:,ii)-Data(:,jj)),inf);%计算相空间中每两点之间的距离,其中NORM(V,inf) = max(abs(V)).
if r>d
%sita=heaviside(r,d);%计算Heaviside 函数之值n
sum=sum+1;
end
end
end
C_I(i)=2*sum/(N_r*(N_r-1));
a=C_I(i)-C_1(i)^m;%对t个不相关的时间序列求和
s_t3=s_t3+a;
end
s_t2(j)=s_t3/t;
s_t1=s_t1+s_t2(j);%对rj求和
end
delt_s_m(m)=max(s_t2)-min(s_t2);%求delt S(m,t)
delt_s_s=delt_s_s+delt_s_m(m);%delt S(m,t)对m求和
s_t0(m)=s_t1;
s_t=s_t+s_t0(m);%S对m求和
end
s(t)=s_t/16;
delt_s(t)=delt_s_s/4;
s_cor(t)=delt_s(t)+abs(s(t));
end
fid=fopen('result.txt','w');
fprintf(fid,'%f %f %f %f/n',t,s(t),delt_s(t),s_cor(t));
fclose(fid);
t=1:max_d;
plot(t,s,t,delt_s,'.',t,s_cor,'*')
运行完之后总会出现如下问题
??? Attempted to access C_1(2); index out of bounds because numel(C_1)=1. 还望各位高手指点
页:
[1]