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 for Programming
 Forum for Origin C
 retrieving fitting parameters after nlsf-sigmaplot
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

deomlew

Posts

Posted - 11/09/2006 :  12:34:26 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.0
Operating System:windowsxp

Hello,

I've just started for the first time trying to write a small script in origin c to plot my data. I simple use the origin programming sample Automation.c

In the original file a gaussian fit is performed, for my data I need a sigmaplot instead. Performing this fit and plotting it in the data-graph works fine, but I somehow cannot get the resulting parameter values. I would like to get the A1, A2 and x0 out of it. This is part of the programm that I'm using:

//Perform nonlinear fit to plotted data
NLSFCntrl nlsfMyFit; // create NLSFcntrl - see OC_Types.h for details
initNLSF(nlsfMyFit); // initialize structure with default initial values
nlsfMyFit.pasteToPlot = false; // turn off pasting results to graph after fitting
lstrcpy(nlsfMyFit.szYdataName, strYDataName); // assign fit dataset name
lstrcpy(nlsfMyFit.szFuncName, "boltzmann"); // assign fitting function name, see fitting assistent in origin
fitNLSF(nlsfMyFit); // perform fit

//Write fit parameters to graph text labels
string strJLimMin, strJLimMax, strSym;
strJLimMin.Format("%f",nlsfMyFit.Par[1]);
strJLimMax.Format("%f",nlsfMyFit.Par[2]);
strSym.Format("%f",nlsfMyFit.Par[3]);

Thanks in advance!

Mike Buess

USA
3037 Posts

Posted - 11/09/2006 :  1:53:48 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
NLSFCntrl has been replaced by a method which uses LabTalk's NLSF object directly. I strongly recommend that you update to 7.0SR4 and consult the updated Automation.c. Your code will look something like this when written for NLSF...

using nlsf = LabTalk.nlsf;
nlsf.Init();
nlsf.PasteToPlot = 0;
nlsf.Func$ = "boltzmann";
nlsf.FitData$ = strYDataName;
nlsf.Execute("parainit"); // estimate parameters
nlsf.Fit(100);

string strJLimMin, strJLimMax, strSym;
strJLimMin.Format("%f",nlsf.p1); // first parameter (A1 = nlsf.p1)
strJLimMax.Format("%f",nlsf.p2); // second parameter (A2 = nlsf.p2)
strSym.Format("%f",nlsf.p3); // third parameter (x0 = nlsf.p3)

Mike Buess
Origin WebRing Member
Go to Top of Page

easwar

USA
1965 Posts

Posted - 11/09/2006 :  1:57:50 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi deomlew,

Looks like the version you have may be 7.0SR0. So first I would recommend that you get a free patch (service release) for your installation to bring it up to 7.0SR4, from our downloads area:
http://www.originlab.com/index.aspx?s=12

Once you have patched to 7SR4, you can then directly address the LabTalk NLSF object in your Origin C code such as:
using nlsf = LabTalk.nlsf;
nlsf.func$="boltzmann";
...
...
nlsf.iterate(100);
...
then you can access fit values with statements such as
double A1 = nlsf.p1;
double A2 = nlsf.p2;
etc

For a complete list of nlsf object properties, please see the LabTalk Language Reference manual.

Easwar
OriginLab



Go to Top of Page

deomlew

Posts

Posted - 11/13/2006 :  04:45:47 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
tnx, now it works fine!
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