用C-C法重构相空间计算参数
在用C-C法重构相空间时,问题是:错误使用 double.heaviside输入参数太多。出错 correlation_integral (line 15)
sita=heaviside(r,d);%calculate the value of the heaviside function
出错 C_CMethod (line 29)
C_1(i)=correlation_integral(Y,N_d,r);%计算C(1,N_d,r,t)
出错 Main (line 2)
=C_CMethod(data);
以下是程序部分:
function =C_CMethod(data)
%this function calculate time delay and embedding demension with C-C
%Method,which proved by H.S.Kim
%skyhawk&flyinghawk
% %****************调试程序段****************************
% clear all;
% data=load('f:/sunpot/year sunpot number.txt');
% %************************************************
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
t
s_t=0;
delt_s_s=0;
for m=2:5
s_t1=0;
for j=1:4
r=sigma*j/2;
data_d=disjoint(data,N,t);%将时间序列分解成t个不相交的时间序列
=size(data_d);
s_t3=0;
for i=1:t
i
Y=data_d(i,:);
C_1(i)=correlation_integral(Y,N_d,r);%计算C(1,N_d,r,t)
X = reconstitution(Y,N_d,m,t);%相空间重构
N_r=N_d-(m-1)*t;
C_I(i)=correlation_integral(X,N_r,r);%计算C(m,N_r,r,t)
s_t3=s_t3+(C_I(i)-C_1(i)^m);%对t个不相关的时间序列求和
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,'*')
TD = FindFistMinimum(delt_s');
s_cor_minValue = FindGlobalMinimun(s_cor')
ED = ceil((s_cor_minValue/TD) + 1);
%% 寻找序列的第一个零点 Fin the first extreme
% 输入:data,为N行一列数据
% 输出:第一个零点
function FindFistMinimumResult = FindFistMinimum(data)
%FindFistMinimumResult = 0;
% ifdata(1) < min(data(2:end,:))
% FindFistMinimumResult =1;
% end
for i = 2 : 1 : size(data,1)-1
if (data(i) < data(i-1) && data(i) < data(i+1))
FindFistMinimumResult = i;
break;
end
end
%% 寻找序列的全局最小点
% 输入:data,为N行一列数据
% 输出:全局最小点,如果输出结果为0,序列所有数据相等
function FindGlobalMinimunResult = FindGlobalMinimun(data)
FindGlobalMinimunResult = 0;
for i = 1 : 1 : size(data,1)
if data(i) == min (data)
FindGlobalMinimunResult = i;
break;
end
end
页:
[1]