T O P I C R E V I E W |
sdpollar |
Posted - 12/12/2015 : 9:06:23 PM Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 9.1, 32bit. Operating System: Windows 7 Enterprise
I'm attempting to do a piecewise curve fit to some data that I have, and keep getting the following errors:
Error, Variable "del" not declared Error, Variable "" not declared Error, general compile error Error, error(s) found in compiling function _nlsfPeicewiseLnDMIfit
My "code" is below, and I have no idea where the problem is coming from (the first doubles are all constants that I need to make use of. Any ideas where the problems are coming from? I'm totally new to this, and am probably making some rookie mistake...
#pragma numlittype(push, TRUE) #pragma numlittype(push, TRUE) #pragma warning(error : 15618) #include <origin.h>
// Add your special include files here. // For example, if you want to fit with functions from the NAG library, // add the header file for the NAG functions here.
// Add code here for other Origin C functions that you want to define in this file, // and access in your fitting function.
// You can access C functions defined in other files, if those files are loaded and compiled // in your workspace, and the functions have been prototyped in a header file that you have // included above.
// You can access NLSF object methods and properties directly in your function code.
// You should follow C-language syntax in defining your function. // For instance, if your parameter name is P1, you cannot use p1 in your function code. // When using fractions, remember that integer division such as 1/2 is equal to 0, and not 0.5 // Use 0.5 or 1/2.0 to get the correct value.
// For more information and examples, please refer to the "User-Defined Fitting Function" // section of the Origin Help file.
//---------------------------------------------------------- // void _nlsfPeicewiseLnDMIfit( // Fit Parameter(s): double psi0, double Hdmi, double vo, // Independent Variable(s): double x, // Dependent Variable(s): double& y) { // Beginning of editable part //dividing by if condition double mu0 = 4e-7*PI double Nx = 0.22 double Hk = 1.4 double A = 1.6e-12 double Ms = 400e3 double K0eff = Hk*Ms/2 double del = 2.3904572186687873e-09 double sigma0 = 2*PI*(A*K0eff)^0.5 double Kd = Nx*mu0*Ms^2/2 double Condition = 4*Kd/(PI*Ms) double theta = 5*2*PI/360 double prefactor = PI^2*del*Ms^2/(8*Kd) if(abs(mu0(x+Hdmi))<Condition) { y=psi0*(H*sin(theta)/sigma0)^(1/4)*((sigma0-prefactor(mu0*x+mu0*Hdmi)^2)^(1/4)+ln(vo) } else { y=psi0*(H*sin(theta)/sigma0)^(1/4)*((sigma0+ 2*Kd*del - PI*del*Ms*abs(mu0*x+mu0*Hdmi)))^(1/4)+ln(vo) } // End of editable part }
|
1 L A T E S T R E P L I E S (Newest First) |
jasonzhao |
Posted - 12/14/2015 : 03:28:47 AM Hello,
I make some modification on the code, so the compile can succeed;
but you need to make a careful check with the formula y=... to make sure the bracket usage is in accord with your mathematic formula.
// Beginning of editable part
//dividing by if condition
double mu0 = 4e-7*PI;
double Nx = 0.22;
double Hk = 1.4;
double A = 1.6e-12;
double Ms = 400e3;
double K0eff = Hk*Ms/2;
double del = 2.3904572186687873e-09;
double sigma0 = 2*PI*(A*K0eff)^0.5;
double Kd = Nx*mu0*Ms^2/2;
double Condition = 4*Kd/(PI*Ms);
double theta = 5*2*PI/360;
double prefactor = PI^2*del*Ms^2/(8*Kd);
if(abs(mu0*(x+Hdmi))<Condition)
y = psi0*(Hk*sin(theta)/sigma0)^(1/4)*(sigma0-prefactor*(mu0*x+mu0*Hdmi)^2)^(1/4)+ln(vo);
else
y= psi0*(Hk*sin(theta)/sigma0)^(1/4)*(sigma0+2*Kd*del - PI*del*Ms*abs(mu0*x+mu0*Hdmi))^(1/4)+ln(vo);
// End of editable part
}
Best regards! Jason OriginLab Technical Service |
|
|