Thanks very much for the help.
I made a lot of mistakes.
I tried another time fixing the mistakes and now the function compiles. But when I simulate or try to fit the data Origin freezes and crashes.
#include <stdio.h>
#include <data.h>
#include <math.h>
#include <utilities.h>
#include <origin.h>
#include <OC_nag.h>
/*
You should follow C-language syntax in defining your function. For instance, if your parameter is P1, you cannot use p1
in your function code. To use temporary variables, you will need to first declare them.
In your function, you can use C functions defined elsewhere, you can access the NLSF object methods and properties etc.
For more information and examples, please refer to the "User-Defined Fitting Function" section of the Origin Help file.
*/
double f_int(double t, int n)
{
return (pow(t,n))/(exp(t)-1)*(1-exp(-t))
}
//----------------------------------------------------------
//
void _nlsfBlochGruenseimD(
// Fit Parameter(s):
double P1, double P2, double P3, double P4,
// Independent Variable(s):
double x,
// Dependent Variable(s):
double& y)
{
// Beginning of editable part
int n;
double y0;
n=2;
double t;
t=1e-6;
y0=36.6465;
y=y0;
double c;
double d;
double e;
double dIntegral;
do // loop over n
{
do //loop over t+dStep
{
// Initialization
double dIntegral = 0.0;
double dTrapezia = 0.0;
// Steps, or Precision.
double dStep = 1e-12;
// Trapezia area.
dTrapezia = 0.5 * (f_int(t, n)+ f_int((t+dStep),n)) * dStep;
// Accumulate area.
dIntegral += dTrapezia; // intregral calculation.
t += dStep;
// }while( (dTrapezia/dIntegral) > dPrecision );
}while(t<=P1/x);
// Perform integrate by trapezoidal rule.
if(n=2)
c=P2;
else if(n=3)
d=P3;
else
e=P4; //n=5
n=n+1;
}while (n<=5);
y= y + c * pow(x,2) * dIntegral+ d * pow(x,3) * dIntegral+e * pow(x,5) * dIntegral;
// End of editable part
}
Can it be due to some trouble of convergence of the function inside the integral?