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
 Origin Forum
 How to include an integration in a Y-script?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

dybdal

Denmark
3 Posts

Posted - 01/23/2002 :  10:49:36 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
How do you type in the following equation as an Y-script for non-linear curve fitting:

y=integral(from T=a to T=b) of k * dT

Mike

USA
357 Posts

Posted - 01/24/2002 :  09:02:50 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi dybdal,

You will want to look over this Knowledge Base item on Fitting with Integrals.

You should also look over the LabTalk documentation for the "Integrate" command and the "Integ" Object (pages 130 and 268 in your 6.0/6.1 Labtalk Manual or go to your online help files -- Help: LabTalk, and look in the index for "Integrate" and "Integ").

I hope this helps.

Mike
OriginLab Tech Support



Go to Top of Page

kfauth

Germany
33 Posts

Posted - 02/06/2002 :  06:04:48 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
dybdal,

the best way to go might depend on how your integral enters in the fitting function. One point is: do you need to calculate the integral once per
fitting iteration (i.e. it only depends on fitting parameters) or once per datapoint of the curve to be fitted (it depends on x (also)).

I have had a related problem (see my post from 12/11/2001).
In my case the criterion related to the parameter p1 (comparison
to the variable store: if(p1 != store) as given in the article Mike refers to
did not work. Also, if you choose to fix this parameter and have others varied, you will have to modify your script.

Instead I use:
if(nlsf.curRow==1){calculate integral once per iteration only}
and this works fine with me (origin 5.0)

Kai

Go to Top of Page

dybdal

Denmark
3 Posts

Posted - 02/07/2002 :  07:59:41 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you Kai,

I havn't solved my problem with integrals in Y-scripts yet. Below i have listed my Y-script:

Before a fit a initialize the variables Tu, Ea and H. I have my x data in Data1_A and the y data in Data1_B.

Data1_C=exp((Ea/2)*((1/((1/(Tu+200))-Data1_A+200))));
integrate Data1_C;
Data1_E=H*Data1_C*(1/1.5)*exp((-1/1.5)*(_integ_area));
Y=Data1_E(X);

If I fit data to my experimental data points I get a nice fit and the values of Ea, Tu and H are respectively: 88700, 88.2 and 585600.

When I run the script from the script window with the above mentioned values I get a very poor fit. Using the script i find that the optimal values are Ea=35000, Tu=103 and H=585600.

The values obtained using the script reflect the the "true" values.

Does anyone have an explanation or a solution?
Go to Top of Page

kfauth

Germany
33 Posts

Posted - 02/12/2002 :  05:07:51 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi again, dybdal.

things will depend on what result of the integration you
want to use.

_integ_area is a dataset containing
_integ_area(x)=int(from a to x over Data1_C)

If, instead (as indicated in your first post) you want the (single)
numerical value int(from a to b over Data1_C)
then this value is stored in the integ object property
integ.area. (it is numerically equivalent to the
last element of _integ_area).

As to why it works differently from script window and
NLSF I don't know. It may have to do with the way x-values
are being assigned in the vector operation *(_integ_area)

Hope this helps

Kai
Go to Top of Page

Jose

Netherlands
93 Posts

Posted - 01/20/2003 :  12:43:16 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
And how could I fit multiple datasets to a function that includes an integral? How can I refer to the proper datasets in the Y-script, if they are in different worksheets? Changing the above script into something like br / br / pre id=code font face=courier size=2 id=code br / %w=%[%c, _; // wks for current dataset
%w_C=...;
integrate $w_C;
%w_E=...;
Y=%w_E(X);


using substitution notation (%w to refer to current wks) doesn't work.

Jose Via, Origin WebRing member

I don't know why I see this post so weird, with a url-link where I haven't put it. Also, the first line of code should end with a closing square bracket before the semicolon.

Edited by - Jose on 01/20/2003 12:48:18 PM
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