T O P I C R E V I E W |
nanomech |
Posted - 01/31/2002 : 08:31:06 AM 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 |
2 L A T E S T R E P L I E S (Newest First) |
nanomech |
Posted - 02/01/2002 : 04:26:36 AM This works fine, thanks!
Patrick |
rtoomey |
Posted - 01/31/2002 : 11:17:37 AM 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
|
|
|