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 for Programming
 Forum for Origin C
 Nonlinear fitting routine help

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
liveforsnow2288 Posted - 08/31/2012 : 3:22:45 PM
Origin Ver. 8 and Service Release 0
Operating System: Windows 7 Professional

Hi all,

I'm trying to create a custom fitting algorithm and am having some troubles. Here is the origin C code that I am using.

#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 _nlsfarrowFCS(
// Fit Parameter(s):
double Dd, double Vz, double Cc,
// Independent Variable(s):
double t,
// Dependent Variable(s):
double& y)
{
// Beginning of editable part
double coff = 1
double wxc = 4.68*10^(-6)
double wy = 1.8198*10^(-6)
double w0 = 2.64*10^7
double L = 12*10^(-6)
double wz = 5.9515*10^(-6)
double r = 0

y = ((1+r^2)^2+2*r^2*exp[-wxc^2*w0^2*Dd*t/(wxc^2+4*Dd*t)]*Cos[2*w0*L]+2*r^2*exp[-wxc^2*w0^2/4]+4*r*(1+r^2)*Cos[w0*L]*Exp[-wxc^2*w0^2/8*(1-wxc^2/(2*wxc^2+8*Dd*t))])/(Cc*pi^(3/2)*Sqrt[4*Dd*t+wxc^2]*Sqrt[4*Dd*t+wy^2]*sqrt[4*Dd*t+wz^2]*(1+r^2+2*exp[(-(1/8)*w0^2*wxc^2)]*r*cos[L*w0])^2)*Exp[-(Vz*t)^2/(wz^2+4*Dd*t)]-0.035*coff
// End of editable part
}

basically what I am trying to do is fit the function y to some set of data by varying the fit parameters. I keep getting undefined variable errors and would much appreciate any guidance.

Thanks
1   L A T E S T    R E P L I E S    (Newest First)
Penn Posted - 09/02/2012 : 11:12:59 PM
Hi,

I found some mistakes in the code you posted.

1. At the each end of the statement, semicolon (;) is needed.

2. Origin C is case sensitive, some functions you used is not right, such as Exp, Cos, etc.

3. Origin C will use parentheses, "()", for each function, but not square brackets, "[]".

The correct code should be:

double coff = 1;
double wxc = 4.68*10^(-6);
double wy = 1.8198*10^(-6);
double w0 = 2.64*10^7;
double L = 12*10^(-6);
double wz = 5.9515*10^(-6);
double r = 0;

y = ((1+r^2)^2+2*r^2*exp(-wxc^2*w0^2*Dd*t/(wxc^2+4*Dd*t))*cos(2*w0*L)+2*r^2*exp(-wxc^2*w0^2/4)+4*r*(1+r^2)*cos(w0*L)*exp(-wxc^2*w0^2/8*(1-wxc^2/(2*wxc^2+8*Dd*t))))/(Cc*pi^(3/2)*sqrt(4*Dd*t+wxc^2)*sqrt(4*Dd*t+wy^2)*sqrt(4*Dd*t+wz^2)*(1+r^2+2*exp((-(1/8)*w0^2*wxc^2))*r*cos(L*w0))^2)*exp(-(Vz*t)^2/(wz^2+4*Dd*t))-0.035*coff;


Penn

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