K
kak3012
Hi all,
I am trying to make a sinusoidal curve fit by using Levenberg-Marquardt
Method with numerical recipies.
I have model the my function which is y=Ao+C1.cos(x+phase) as at the end of
this message.
From that point on I am confused about what to do. I know I need to use
mrqcof function but could not figure it out how to use use it becase the
function looks like more advaced to me which is
void mrqcof(float x[], float y[], float sig[], int ndata, float a[], int
ia[],
int ma, float **alpha, float beta[], float *chisq,
void (*funcs)(float, float [], float *, float [], int))
I am using Visual Studio.Net 2003 so I have transfered this function as
typedef void (*funcs)(float,float [],float *,float [],int);
void mrqcof(float x[], float y[], float sig[], int ndata, float a[], int
ia[],int ma, float **alpha, float beta[], float *chisq,funcs MyComp);
Now I do not know what to do?
Can anyone help me or forward me to some examples? I could not find much on
the internet by myself..
Thanks....
void model(float x, float a[], float *y, float dyda[], int na)
{
float fac,Mcos,Msin;
*y=0.0;
for(int i=1;i<na-1;i+=3)
{
Mcos=cos(x+a[i+2]);
Msin=sin(x+a[i+2]);
fac=-a[i+1]*sin(x+a[i+2]);
*y+=a+(a[i+1]*Mcos);
dyda=1;
dyda[i+1]=Mcos-(a[i+1]*Msin);
dyda[i+2]=-a[i+1]*Msin;
}
I am trying to make a sinusoidal curve fit by using Levenberg-Marquardt
Method with numerical recipies.
I have model the my function which is y=Ao+C1.cos(x+phase) as at the end of
this message.
From that point on I am confused about what to do. I know I need to use
mrqcof function but could not figure it out how to use use it becase the
function looks like more advaced to me which is
void mrqcof(float x[], float y[], float sig[], int ndata, float a[], int
ia[],
int ma, float **alpha, float beta[], float *chisq,
void (*funcs)(float, float [], float *, float [], int))
I am using Visual Studio.Net 2003 so I have transfered this function as
typedef void (*funcs)(float,float [],float *,float [],int);
void mrqcof(float x[], float y[], float sig[], int ndata, float a[], int
ia[],int ma, float **alpha, float beta[], float *chisq,funcs MyComp);
Now I do not know what to do?
Can anyone help me or forward me to some examples? I could not find much on
the internet by myself..
Thanks....
void model(float x, float a[], float *y, float dyda[], int na)
{
float fac,Mcos,Msin;
*y=0.0;
for(int i=1;i<na-1;i+=3)
{
Mcos=cos(x+a[i+2]);
Msin=sin(x+a[i+2]);
fac=-a[i+1]*sin(x+a[i+2]);
*y+=a+(a[i+1]*Mcos);
dyda=1;
dyda[i+1]=Mcos-(a[i+1]*Msin);
dyda[i+2]=-a[i+1]*Msin;
}