### Higuchi method for fractal dimension

double lreg(int k, double v1[], double v2[]){
double x,y,cn=0.0,sumx=0.0,sumy=0.0,sumxy=0.0,sumx2=0.0;
double d1,d2;
cn=(double)k;
for(int i=0; i<k; i++){
x=v1[i]; //x variable
y=v2[i]; //y variable
sumx+=x;
sumy+=y;
sumxy+=x*y;
sumx2+=x*x;
}
d1=(cn*sumxy-sumx*sumy);
d2=(cn*sumx2-sumx*sumx);
if(fabs(d1)<1.e-10 || fabs(d2)<1.e-10) return 0.0;
else return d1/d2;
}

int main (int argc, char **argv)
{
int i,m,x,k=10;
double v1[10],v2[10],Lmk[10],Lmk1[20],FD,Hmax,Ng;

Lmk[0] = 0.0;Lmk1[0] = 0.0;
double Lk=0.0;
for(m=1;m<=k;m++)
{
Hmax =(int)((N-m)/k);
}
for(x=1;x<=N;++x)
{
for(i=0;i<=Hmax;i++)
{
Lmk[i]= abs(x*(m+i*k) - x*(m*(i-1)*k));
}
}
Ng = (N-1)/(Hmax)*k;
for(i=0;i<=Hmax;i++)
{
Lmk1[i] = (Lmk[i]*Ng)/k;
Lk+= Lmk1[i];
for(i=0;i<10;i++)
{
v1[i] = -log(Lk);
v2[i] = log (1./k);
}
FD =lreg(10,v1,v2);
printf("fractal dimension is %f",FD);
}
return(0);
}
NB: Please go through this code;its running successfully but not displaying the results for the Fractal dimension (FD).the output console is just blank even with 'cout' command.Can anyone pls tell me what is wrong?
Topic archived. No new replies allowed.