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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Failed to build equation with Origin C
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Martta

Finland
3 Posts

Posted - 04/09/2013 :  04:43:57 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello all,

I'm working with Origin 8.6 and trying to finish my Master's thesis. I am trying to build equation with Origin C but I can't get it right. Here's the equation:

if ( x < Topt )
y=Iopt*exp*(-2,3*(x-Topt)^2/(Tinf-Topt));
else if ( x > Topt )
y=Iopt*exp*(-2,3*(x-Topt)^2/(Tsup-Topt));

When I go to Code Builder, I get the message "Compile error". This is what happens in the Code builder:

//----------------------------------------------------------
//
void _nlsfLehmann(
// Fit Parameter(s):
double Iopt, double Topt, double Tsup, double Tinf,
// Independent Variable(s):
double x,
// Dependent Variable(s):
double& y)
{
// Beginning of editable part
if ( x < Topt )
y=Iopt*exp*(-2,3*(x-Topt)^2/(Tinf-Topt));
else if ( x > Topt )
y=Iopt*exp*(-2,3*(x-Topt)^2/(Tsup-Topt));

// End of editable part
}



I would really appreciate your help.

Thank you,
Martta

malgoska

Poland
36 Posts

Posted - 04/09/2013 :  05:09:07 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,
there are few issues with your function:
1. the if-else statements has syntax
if(condition1) statement1;
else statement2;

so you don't need another if
2. use dots instead of commas as decimal mark
3. no need for asterisk after exponent.

Your function should look like this:
// Beginning of editable part
if ( x < Topt ) y=Iopt*exp(-2.3*(x-Topt)^2/(Tinf-Topt));
else y=Iopt*exp(-2.3*(x-Topt)^2/(Tsup-Topt));
// End of editable part


Regards,
Margaret
Go to Top of Page

Martta

Finland
3 Posts

Posted - 04/09/2013 :  06:53:34 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you so very much, it's working now!

Best regards,
Martta
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000