Origin Version: OriginPro 8GSr1
Operating System: Win XP
Hello,
I have data which can be fitted to:

The integration is from 0 .. 2pi.
I tried to implement this as a user-defined fit function in OriginC.
Here is my code:
#pragma warning(error : 15618)
#include <origin.h>
#include <OC_nag8.h>
void test () {
double f;
_nlsfKraftPM (1,10,f); //berechne F(10) mit k = 1
printf("test %f",f);
}
double NAG_CALL integrand(double phi) {
double a = 0.06;
double b = 0.06;
double ta = 0.06;
double tb = 0.06;
double c=sqrt(a^2 + b^2 - 2 * a * b * cos (phi));
double d = (h + ta + sqrt(c^2 + (h+ta)^2)) * (h + tb + sqrt(c^2 + (h+tb)^2));
double e = (h + sqrt(c^2 + h^2)) * (h + ta + tb + sqrt(c^2 + (h+ta+tb)^2));
return cos(phi) * ln(d/e);
}
void _nlsfKraftPM(
// Fit Parameter(s):
double k,
// Independent Variable(s):
double h,
// Dependent Variable(s):
double& F)
{
// Beginning of editable part
const double a = 0.06;
const double b = 0.06;
//Parameter für die NAG-Funktion d01ajc
double ug = 0.0;// untere Grenze
double og = 2*3.14159;// obere Grenze
double epsabs = 0.0;// absoulte accuracy
double epsrel = 0.001;// relative
Integer max_num_subint = 500; // maximale Anzahl der Subintervalle
double result;// Ergebnis
double abserr;
Nag_QuadProgress qp;
NagError fail;
fail.code = NE_NOERROR;
//integrieren der Funktion integrand
d01ajc (integrand, ug, og, epsabs, epsrel, max_num_subint, &result, &abserr, &qp, &fail);
// Berechnen von F
F = k * a * b * result;
// End of editable part
}
And this is my problem: The function integrand needs the value of h, which is a parameter of _nlsfKraftPM. I think that I can't change the number of parameters of integrand because it is called by the nag function d01ajc. So I don't know how to reach h in integrand. I also tried to write the value of h in a variable that is defined outside of the functions and acces this variable in integrand. This resulted in a runtime error.
Do you have any ideas what I could do to solve this probelm?
Is there another way to implement this fit-function?
Thank you very much for your help
Michael Becker