From: vo quang ha on
I have tried calculating a fractal dimension (FD) trace using Higuchi's algorithm .In Theory,FD must be between 1-2 .My problem is: sometimes, when I run my code , the FD is greater than 2 .Have u ever met this situation before?can u give me some advise ?Thks so much
My code:
function higuchi(data,windowsize,kmax)
format long
clear L;
N=windowsize;
Df_matrix=[];
for v=1:(length(data)-windowsize)
trace=data(v:(v+N));
for k=1:kmax,
for m=1:k,
L(m,k)=0;
for i=1:fix((N-m)/k),
L(m,k)=L(m,k)+abs(trace(m+i*k)-trace(m+(i-1)*k));

end
L(m,k)=((N-1)/(fix((N-m)/k)*k))*L(m,k)/k;
a=(N-1)/(fix((N-m)/k)*k);

end
end

for k=1:kmax,
L_mean(k)=mean(nonzeros(L(:,k)));
end
k=1:kmax;
X(k)=log(1./k);
Y=log(L_mean);
D=polyfit(-log(k),log(L_mean),1);
Df=D(1);
Df_matrix=[Df_matrix Df];

end
figure
plot(Df_matrix,'black')
mean(Df_matrix)