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
 Setting variable bounds in NLfit
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

DaveGohlke

USA
3 Posts

Posted - 02/10/2012 :  8:09:50 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 8.0 SR6:
Operating System: Win 7, 32bit.

I am trying to fit a custom non-linear function for many files with varying x values and different numbers of peaks. (Each individual curve will be fit by the sum of two exponentials and several Gaussians.) Is it possible to programmatically set my Upper/Lower bounds for any variable?

Currently, if there is one peak, and I ask for two Gaussians, the function might return one good Gaussian, and then one Gaussian centered outside of my range, with an unphysical width or height.

I could hard-code my bounds in for each set of data if necessary, or manually filter the data in post-processing, but I want this to require as little human input as possible.

My first work-around has been to add two new parameters in the initialization:
maxx = max(x_data);
minx = min(x_data);

and then define my function as
y = AVB*exp(-x/tVB) + ACB*exp(x/tCB) +y0 + A1*exp(-((x-xc1)/w1)^2);
maxx; minx;
if(w1 > (maxx-minx) || xc1 > maxx || xc1 < minx)
{
A1 = 0;
xc1 = 0;
w1 =1;
}

I'm a little concerned about convergence issues with this method (I think it might risk going in a loop), and would much prefer to set bounds as:
0 < w1 < max(x_data) - min(x_data)
min(x_data) < xc1 < max(x_data)
Can one adjust the bounds more variably in the parameter settings than "0(X, On)", "--(I, Off)"?

Thanks,
Dave

PS: Sorry for overwhelming the forum with consecutive topics. I figured they were distinct enough to merit it.

easwar

USA
1964 Posts

Posted - 02/14/2012 :  12:03:30 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Dave,

You can control the fitting programmatically by getting a tree of all parameter settings and manipulating that tree. See this wiki page for examples:
http://wiki.originlab.com/~originla/ltwiki/index.php?title=LabTalk:Curve_Fitting

This information is also in the LabTalk help files. You have version 8, so the wiki is more up to date, and some commands/options in there are only available in 8.6, so you may want to try with the 8.6 demo.

If you need more help with programming, contact tech support, or post in the LabTalk forum.

Easwar
OriginLab
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