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
 fitting in a loop
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

vassilios_1

Germany
4 Posts

Posted - 07/23/2004 :  05:17:03 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi everybody,

I'm trying to fit a lot of Gauss curves each plotted in a separate window using a loop:
loop(i,1,150)
{
nlsf.cleanupfitdata();
win -a Peak$(i); #activate window Peak1,...
nlsf.func$ = gauss; #fit function
nlsf.fitdata$ = %C; #active dataset
nlsf.xBegin = 19.5;
nlsf.xEnd = 21.5;
nlsf.fit(10);
}
Sometimes Origin does the fitting well, sometimes it draws just a constant value or some ill-shaped curve. Why is Origin so unreliable?
If I use other fit functions like Lorentz or Voigt sometimes very stupid comments appear: "Try keeping "xc" constant". How now?

I'm tired struggling with Origin.

I'm grateful for any comment or even a better working code.
Thanks a lot!!





easwar

USA
1965 Posts

Posted - 07/23/2004 :  10:25:17 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I think you are encountering problems because there is no parameter initialization being done in your code. Thus the starting parameter values may be set to some default such as 0 or 1, and the minimization algorithm/fit fails to converge. When that occurs, you could end up with a bad fit curve, or messages asking you to fix a particular parameter or other.

What version of Origin are you using? If you have version 7.0 or higher, you can add a script line:
nlsf.execute(parainit);
to auto initialize the parameters once you have chosen you fitting function and assigned datasets.

If you are running earlier versions, you may need to manually set the parameter values in your code, such as:
nlsf.p1=somevalue;
nlsf.p2=somevalue;
or use some functions to guess good initial values (which is what is done in version 7 and later using parainit).

Then the fit should converge better.

If you have more questions, please post or contact tech support directly for further help with scripting.

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