The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum
 Origin Forum
 How do I call my own function in NLCF (Origin 7.5)

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
lulisa Posted - 05/27/2010 : 5:04:59 PM
I have a problem with the nonlinear curve fitting tool in Origin 7.5.
I'm trying to create my own user-defined function by calling another function that I created in C++, but it doesn't compile. I added my erf function .h file to origin.h, and it still won't work.

Here is what I have in the nonlinear curve fitting function:

#include <Origin.h>

y = A*exp(B*x^(d-1))*(1-c*erf(x^(d/2-1/2)));



And here is what I coded for the erf function:

#include <Origin.h>

double erf (double x)
{
static const double two_sqrtpi = 1.12838;
static const double rel_error = 1E-12;
if (abs(x) > 2.2) {
return 1.0 - erfc(x);
}
double sum = x, term = x, xsqr = x*x;
int j = 1;
do{
term*=xsqr/j;
sum-= term/(2*j+1);
++j;
term*= xsqr/j;
sum+= term/(2*j+1);
++j;
}
while (abs(term)/sum > rel_error);
return two_sqrtpi*sum;
};
1   L A T E S T    R E P L I E S    (Newest First)
Shirley_GZ Posted - 05/28/2010 : 03:06:59 AM
Hi Lulisa,

The declaration of function "erf" conflicts with that of an internal function. Please change the name to another, such as "erf1".

I also noticed that you used the function "erfc", I wonder whether you were calling an internal function "nag_erfc" or just calling a function defined by yourself. If the former, please use the right function name.

In addition, when you call this function in the nonlinear curve fitting function, you should add the header file for this function firstly, such as #include<erf.h>.

Best regards,
Shirley


Originlab Technical Service Team

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000