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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Multiple find X's in a polynomial fit

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
stephenbks 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
1   L A T E S T    R E P L I E S    (Newest First)
zachary_origin 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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000