|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
我用计算关联维数的程序算了一组数,但是输出却是:
ans =
0 0 0 0 0
0 0 0 0 0
-0.6296 0.0635 0.4690 0.7567 0.9798
-0.6296 0.0635 0.4690 0.7567 0.9798
-0.6296 0.0635 0.4690 0.7567 0.9798
-0.6296 0.0635 0.4690 0.7567 0.9798
-0.6296 0.0635 0.4690 0.7567 0.9798
-0.6296 0.0635 0.4690 0.7567 0.9798
我看到前面有些帖子里写的计算结果都是两组矩阵,一组是ln_r,一组是ln_C。为什么和我的不一样啊?是不是修改了程序?
我用的程序为:
function [ln_r,ln_C]=G_P(data,N,tau,min_m,max_m,ss)
% the function is used to calculate correlation dimention with G-P algorithm
% data:the time series
% N: the length of the time series
% tau: the time delay
% min_m:the least embedded dimention m
% max_m:the largest embedded dimention m
% ss:the stepsize of r
%skyhawk
load('D:\轴承数据\12k Drive End Bearing Fault Data\IR007_0.mat');
data=X105_DE_time(1:5000);
N=length(data);
tau=2;
min_m=3;
max_m=8;
ss=5;
for m=min_m:max_m
Y=reconstitution(data,N,m,tau);%reconstitute state space
M=N-(m-1)*tau;%the number of points in state space
for i=1:M-1
for j=i+1:M
d(i,j)=max(abs(Y(:,i)-Y(:,j)));%calculate the distance of each two
end %points in state space
end
max_d=max(max(d));%the max distance of all points
d(1,1)=max_d;
min_d=min(min(d));%the min distance of all points
delt=(max_d-min_d)/ss;%the stepsize of r
for k=1:ss
r=min_d+k*delt;
C(k)=correlation_integral(Y,M,r);%calculate the correlation integral
ln_C(m,k)=log(C(k));%lnC(r)
ln_r(m,k)=log(r);%lnr
fprintf('%d/%d/%d/%d\n',k,ss,m,max_m);
end
plot(ln_r(m,:),ln_C(m,:));
hold on;
end
fid=fopen('D:\lnr.txt','w');
fprintf(fid,'%6.2f %6.2f\n',ln_r);
fclose(fid);
fid = fopen('D:\lnC.txt','w');
fprintf(fid,'%6.2f %6.2f\n',ln_C);
fclose(fid);
function X=reconstitution(data,N,m,tau)
%该函数用来重构相空间
% m 为嵌入空间维数
% tau 为时间延迟
% data 为输入时间序列
% N 为时间序列长度
% X 为输出,是m*n 维矩阵
M=N-(m-1)*tau;%相空间中点的个数
for j=1:M %相空间重构
for i=1:m
X(i,j)=data((i-1)*tau+j);
end
end
function C_I=correlation_integral(X,M,r)
%the function is used to calculate correlation integral
%C_I:the value of the correlation integral
%X:the reconstituted state space,M is a m*M matrix
%m:the embedding demention
%M:M is the number of embedded points in m-dimensional space
%r:the radius of the Heaviside function,sigma/2<r<2sigma
%calculate the sum of all the values of Heaviside
%skyhawk
sum_H=0;
for i=1:M
fprintf('%d/%d\n',i,M);
for j=i+1:M
d=norm((X(:,i)-X(:,j)),inf);%calculat the distances of each two points in matris M with sup-norm
sita=heaviside(r-d);%calculate the value of the heaviside function
sum_H=sum_H+sita;
end
end
C_I=2*sum_H/(M*(M-1));%the value of correlation integral
我将reconstitution和correlation_integral两个函数都写在一个.M文件里了,应该不会有影响吧。本人新手,刚开始学习分形和MATLAB,希望得到高手帮助。 |
|