Author |
Topic |
|
DaveGohlke
USA
3 Posts |
Posted - 02/10/2012 : 8:09:50 PM
|
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
|
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
|
|
|
|
Topic |
|
|
|