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
 LabTalk Forum
 Shared Paremeters
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

jeroen.spi

USA
2 Posts

Posted - 03/11/2002 :  3:10:38 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Can the 'Parameter Sharing (click to toggle)' available under the Advanced Fitting Tool (DataSet Tab) functionality be accomplished from LabTalk or Origin C. I have not found anything in the documentation on how to accomplish this.

Example code would be nice! I'm using Origin70Beta7 until me release copy arrives.

rtoomey

USA
184 Posts

Posted - 03/13/2002 :  3:35:51 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You can use general linear constraints to effectively share a parameter between two datasets when fitting them simultaneously. For instance, try the following:

1. Import GaussFit.DAT from the Origin7\Samples\Data folder.
2. Plot columns B and D. Note their peak centers are nearly identical.
3. Open the Nonlinear Curve Fitter and select the Gauss function.
4. Select Options:Control in the fitter.
5. Enable the Enabled check box for General Linear Constraints.
6. Select Function:Save in the fitter to save the function.
7. Close the fitter and activate the graph.
8. Execute the following script in the Script window.

nlsf.init(); // initialize fitter to prep it for fitting session
nlsf.func$="gauss"; // set fitting function
nlsf.numFitSets=2; // define two datasets to be fitted
nlsf.y1$="gaussfit_b"; // set 1st dataset to be fitted
nlsf.y2$="gaussfit_d"; // set 2nd dataset to be fitted
nlsf.execute(ParaInit); // execute parameter initialization routine (new to 7.0)
nlsf.constr$=""; // clear constraints if any were there before
nlsf.constr$="xc=xc_2;"; // set constraints
nlsf.iterateEX(1000); // iterate 1000 times as if clicking Iterate button in fitter (new to 7.0)
nlsf.end(); // end fitting session and output results to plot, results log, and nlsf worksheet

Note: The constraints could be "built" by checking the number numFitSets property. For instance:

%Z="xc"; // initialize constraint statement
loop(ii,2,nlsf.numFitSets)
{
%Z=%Z=xc_$(ii); // build constraint statement
}
%Z="%Z;"; // add semi-colon to %Z

You would then assign %Z to nlsf.constr$ instead of manually entering the constraint. Of course, numFitSets can be set using a variable and that same variable could then be used in the loop instead of numFitSets. In doing this you could free yourself from hard coding the number of datasets you can fit at one time.



Hope this helps...

- rtoomey

P.S. I must apologize for not coming to you with this solution way back in February of 2001! I see you asked the same question then. Just to let you know, I added your name to a suggestion way back then to allow for an easier way to share parameters through script. I'll update the item's priority to see if we can get someone working on this soon.
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