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 xyz data
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

nanomech

Switzerland
3 Posts

Posted - 01/31/2002 :  08:31:06 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello
I have the following problem:
I have a xyz-dataset and I would like to perform a fit using a function like
z=ax+by+c where x and y are the independent variables.
Does someone has a script to do this ?
Thanks
Patrick

rtoomey

USA
184 Posts

Posted - 01/31/2002 :  11:17:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Presuming you've already defined the function in the NLSF, here's a sample script you could use. The script assumes your are working from a worksheet that contains three columns. The first and second columns are your independent variables and the third column is your dependent variable. During fitting it is best to set up the column designations so that they are XYY. When you are done fitting, you can then reset the third column as a Z column for plotting (if you so desire).

nlsf.init(); // initialize fit
nlsf.func$="MyFunc"; // select function called MyFunc to use during fitting
nlsf.x1$=%(%H,1); // select 1st column as independent variable #1
nlsf.x2$=%(%H,2); // select 2nd column as independent variable #2
nlsf.y$=%(%H,3); // select 3rd column as dependent variable
nlsf.p1=1; // initialize parameters
nlsf.p2=1; // (you may have more than two)
nlsf.iterate(100); // perform fit
nlsf.end(); // end fitting session and create curve, fit label, and results log output
layer -a; // rescale the graph to see the fit

NOTE: Although the fit result will be correct, Origin's NLSF is not designed to display the fit curve in three dimensions. Instead, the NLSF plots the fit curve against its associated X column in a 2D graph and includes your original data plotted against its associated X column.

Therefore, when defining your fitting function, it is best to set the Fit Curve group on the After Fitting page to Same X as Fitting Data. This results in a better 2D representation of the fit than would be produced by a Uniform X setting (since both your original data and the fit data will be plotted against the same X column).

Also, make sure you save this setting with your fitting function. To save a fitting function, select Function : Edit and click the SAVE button. The Function menu is accessible when the fitter is in the advanced mode. To proceed to the advanced mode, click on the MORE button in the bottom right corner of the NLSF window. If you see a Basic Mode button, you are already in the advanced mode.

- rtoomey



Go to Top of Page

nanomech

Switzerland
3 Posts

Posted - 02/01/2002 :  04:26:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
This works fine, thanks!

Patrick
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