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
 Labtalk Nonlinear curve fitter

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
simarwood Posted - 11/08/2004 : 09:28:12 AM
I use Origin 6.0 and am completely new to Labtalk.

I want to fit my own defined function {y = k + (1-exp(-x/tor))} to data in an iterative manner (with time, per second) and churn out the chi-squared and parameter data at each time point.

Can anybody help me on where to get started / learn more?

I assume I need to run a loop to keep fitting the response whilst incrementing the last data point to fit by one each time.

4   L A T E S T    R E P L I E S    (Newest First)
easwar Posted - 11/09/2004 : 09:20:07 AM
Hi,

As long as you create the FDF with the function you want to fit with, the code segment posted here can work with the FDF, but you will need to change the parameter initialization code accordingly. Note that I just used some hard coded values such as p1=1. You may want to replace that with your own code, or you may want to enter the para init code in the FDF itself and then call the appropriate nlsf method to run the para init code.


Easwar
OriginLab

simarwood Posted - 11/09/2004 : 05:25:31 AM
I have realised I threw you a bit of a dummy, the curve should be:

y=k+(p1*(1-exp(-(x-21)/p2)))

But if I define this function properly then I suppose it shouldnt affect the code you sent
simarwood Posted - 11/09/2004 : 05:18:15 AM
Many thanks for the script example. It didn't work, but it has given me some idea of the way in which the code is written.

I wish it was Excel Basic, this labtalk stuff is difficult!

easwar Posted - 11/08/2004 : 12:15:11 PM
Hi,

I presume you want to fit to a different section of the data each time. You can do this by programming the LabTalk nlsf object. You can then use the mks1 and mks2 system variables to set data markers to select various subsets of our data and fit each subset using a loop.

A crude example is pasted below. You could look in LabTalk help files for details and then refine the example as needed.

Before you run code (such as this), I suggest you first define/create a new fitting function and then save that function (in the example below, I call it MyFunc). You can then load your special function from the code such as below and then fit with it.

To try this code, first create your function, then graph your data, then copy and paste all lines of the code to the Script window, select/highlight all the lines, and press Enter key to execute.

Easwar
OriginLab


// Get length of active dataset
limit %c;
// Number of groups =length / 10
numgroup = (limit.size) / 10;
// Initialize NLSf object
nlsf.init();
// Assign function
nlsf.func$="myfunc";
// Point to active dataset
nlsf.fitdata$=%c;
// Loop over each group of points in active dataset
for(i = 1; i <= numgroup; i++)
{
// Use mks1, mks2 to set data markers
mks1 = 1 + (i - 1) * 10;
mks2 = i * 10;
// Give some initial value to parameters
// Can be replaced with more elaborate initialization code
nlsf.p1=1;
nlsf.p2=0.1;
// Iterate
nlsf.iterate(100);
// Report to script window
type Data Fitted from $(mks1) to $(mks2);
type Param1: $(nlsf.p1) +/- $(nlsf.e1);
type Param2: $(nlsf.p2) +/- $(nlsf.e2);
type Reduced ChiSqr: $(nlsf.chisqr);
type "";
}



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