Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Fractal dimension using Higuchi's algorithm

Subject: Fractal dimension using Higuchi's algorithm

From: vo quang ha

Date: 9 Mar, 2010 04:54:05

Message: 1 of 3

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)

 

Subject: Fractal dimension using Higuchi's algorithm

From: sadasd

Date: 13 Apr, 2010 17:33:26

Message: 2 of 3

Hello vo quang ha,
Did you manage to fix this problem?

Subject: Fractal dimension using Higuchi's algorithm

From: Roger Stafford

Date: 15 Apr, 2010 01:20:06

Message: 3 of 3

"vo quang ha" <voquangha2003@yahoo.com> wrote in message <hn4k9d$278$1@fred.mathworks.com>...
> 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)
> .......
-----------------
  Hello, Vo Quang Ha and Sadasd. I have checked out the 'higuchi' code and can find nothing in it that would cause errors. There are things you could do that would make the code a little more robust by such things as

1. replacing

 L_mean(k) = mean(nonzeros(L(:,k)));

with

 L_mean(k) = mean(L(1:k,k));

There is no need for it to be searching for non-zeros when you already know the range of rows in L that need to be covered.

2. You could also allocate L a definite amount of space early on rather than just clearing it initially and then letting it build up one column at a time. Just do:

 L = zeros(kmax);

3. There are three lines that don't do anything useful involving 'a', 'X', and 'Y'.

4. It is a bad policy to use the name of an already existing matlab function, as in the case of 'trace' - the variable should be called something else.

5. As the code stands, it never processes the last entry in 'data'. You should have

 for v=1:(length(data)-N+1)
    tracexx=data(v:v+N-1);

  As I have indicated, however, in spite of these considerations the code looks basically valid to me. I have made a number of experimental runs with it. When it is faced with data that has some overlying continuity combined with some randome noise, the resulting fractal dimension lies safely within the interval between 1 and 2. However, in the face of pure noise, as for example letting data be generated by the 'rand' function, Df can climb up to and even exceed 2 by small amounts. By feeding in "malicious" data such as almost entirely alternating -1's and +1's, the value of Df can even be forced well above 3. I do not consider that this invalidates the algorithm. Having the fractal dimension lying within [1,2] is only a statistical claim and it is easy to defeat this with aberrant kinds of data irregularities.

Roger Stafford

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us