Author |
Topic  |
|
stephenbks
USA
Posts |
Posted - 11/27/2006 : 12:10:33 AM
|
Origin Version (Select Help-->About Origin): 7.5 Operating System: Win
I am trying to do a pretty simple script in Origin, but I am having trouble since I am quite a newbie to the program.
Ok, so I have a set of data (2 dimensions), and I want to fit a 6th order polynomial to it and then pull out the x-values for three particular y-values. If I were doing this sort of analysis by hand, it would be trivial. All I would have to do is copy the data into the Data1 cells, Tools -> Polynomial Fit, and then choose the order of the fit, fit it, and then pick out my three data points. The only issue is that I need to do this several hundred times, and so I was hoping that I would not have to do this entirely by hand if there were a faster way to do this through Origin.
FYI, I also have Igor Pro, so if there is a faster way to do this in Origin, than I am all ears on it also.
Thanks, Stephen Burks
|
|
zachary_origin
China
Posts |
Posted - 11/28/2006 : 03:49:27 AM
|
1. For the LabTalk script to do the polynomial fitting, you can reference the following example from Origin Programming Help (Help: Programming: LabTalk Language Reference: Object Reference: Alphabetical List of Objects: Stat).
This script performs a second order polynomial regression. It assumes that a Data1 worksheet is active and contains four columns: an X column with data, a Y column named B with data, an empty column named fitx, and an empty column named fity.
First create a script file containing the following script and save this file as PolyNom.OGS to your Origin software folder:
//Performs polynomial regression //%1 = order //%2 = name of dataset to fit (y variable) //%3 = name of dataset to store fitted x data //%4 = name of dataset to store fitted y data //%5 = number of points to create fitted curve
[main] stat.reset(); //Reset the DLL stat.pr.order = %1; //order stat.data$ = %2; //dataset to fit stat.fitxdata$ = %3; //dataset to store fitted x values stat.fitYdata$ = %4; //dataset to store fitted y values stat.makeX.fitnpts = %5; //number of points of regression curve limit %2; //finds limiting values for the dataset to fit stat.makex.fitx1 = limit.xmin; stat.makex.fitx2 = limit.xmax; stat.makex(); stat.PR();
Then execute the following script to run the script file and perform the polynomial regression:
run.section(polynom.ogs, main, 2 data1_b data1_fitx data1_fity 100);
2. After fitting, to get the x-values for particular y-value, you can use yDataset(interpolatedXValue) =. For example, in above example, add a line after run.section(...): x1 = data1_fity(35) to get the x-value for y at 35.
Zachary OriginLab Technical Services.
Edited by - zachary_origin on 11/28/2006 03:50:30 AM |
 |
|
|
Topic  |
|
|
|