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
 Origin Forum
 Non-linear curve fit for "variable equation"

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
espenhjo Posted - 03/31/2003 : 07:34:35 AM
I have an equation y, that is a double-exponential function of g. In this equation the parameters Dm and D2m also are a function of g. Dm and D2m are given as a function of g, and include the parameters D and D2 that are the parameters that I am interested in.

This means that I have to fit y to all the Dm's and D2m's at the same time as D and D2 are optimized.

What is the best way to do this in Origin 7?

Regards,
EJ
3   L A T E S T    R E P L I E S    (Newest First)
easwar Posted - 04/02/2003 : 11:55:05 AM
Hi EJ,

If I understand you correctly, you only have one indep variable (x) and one dependent variable (y) that you get from your measurements. So there is no need to create additional temporary datasets. All you need are (temporary) variables in your function computation. See the code posted below.

Also, in your code you are computing b1, b2 and t1 using t2 - so you should have only D1, D2 and t2 as your parameters, plus your constants of ld and bd.

I am assuming here that you will be using Origin C to define your function. Not sure why you get compile errors - could be just syntax issues that you need to fix. In any case, if you don't have the latest service release (SR3) I recommend that you get the service release first and then try.

If you need further help, please post with specifics, or contact your tech support office - send them your FDF file, your OPJ with data etc. if necessary.

The FDF file that I created can be downloaded from here:
http://www.originlab.com/ftp/forum_and_kbase/files/EJ.fdf

The function, in Code Builder view, should look like what I paste here below. This code compiles fine in 7SR3.


Easwar
OriginLab.


#pragma warning(error : 15618)
#include <stdio.h>
#include <data.h>
#include <math.h>
#include <utilities.h>
/*
You should follow C-language syntax in defining your function. For instance, if your parameter is P1, you cannot use p1
in your function code. To use temporary variables, you will need to first declare them.
In your function, you can use C functions defined elsewhere, you can access the NLSF object methods and properties etc.
For more information and examples, please refer to the "User-Defined Fitting Function" section of the Origin Help file.
*/

//----------------------------------------------------------
//
void _nlsfEJ(
// Fit Parameter(s):
double D1, double D2, double t2,
// Independent Variable(s):
double x,
// Dependent Variable(s):
double& y)
{
const double ld=10;
const double bd=20;
// Beginning of editable part
double t1=1-t2;
double b1=t1/(t1+t2);
double b2=1-b1;
double Dm1=0.5*(D1+D2+(26747.5*x*ld)^(-2)*((1/t1)+(1/t2))*100+((D2-D1+(26747.5*x*ld)^(-2)*((1/t2)-(1/t1))*100)^2+4/((26747.5*x*ld)^4*t1*t2*1e-4))^0.5);
double Dm2=0.5*(D1+D2+(26747.5*x*ld)^(-2)*((1/t1)+(1/t2))*100-((D2-D1+(26747.5*x*ld)^(-2)*((1/t2)-(1/t1))*100)^2+4/((26747.5*x*ld)^4*t1*t2*1e-4))^0.5);
double bm2=(Dm2-Dm1)^(-1)*(b1*D1+b2*D2-Dm1);
double bm1=1-bm2;
y=10*(bm1*exp(-(26747.5*x*ld)^2*Dm1*bd*1e-5)+bm2*exp(-(26747.5*x*ld)^2*Dm2*bd*1e-5))+100;
// End of editable part
}


espenhjo Posted - 04/02/2003 : 05:12:36 AM
My set of equations actually consists of the dependent variables y, Dm1, Dm2 and bm2.

The thing is that I have an experimental dataset containing the variables x and y. I do not have the variables Dm1, Dm2 and bm2 that also are functions of x and included in the equation for y.

The set of equations look like:

y=I0*(bm1*exp(-(26747.5*x*ld)^2*Dm1*bd*1e-5)+bm2*exp(-(26747.5*x*ld)^2*Dm2*bd*1e-5))+I00;

Dm1=0.5*(D1+D2+(26747.5*x*ld)^-2*((1/t1)+(1/t2))*100+((D2-D1+(26747.5*x*ld)^-2*((1/t2)-(1/t1))*100)^2+4/((26747.5*x*ld)^4*t1*t2*1e-4))^0.5);

Dm2=0.5*(D1+D2+(26747.5*x*ld)^-2*((1/t1)+(1/t2))*100-((D2-D1+(26747.5*x*ld)^-2*((1/t2)-(1/t1))*100)^2+4/((26747.5*x*ld)^4*t1*t2*1e-4))^0.5);

bm2=(Dm2-Dm1)^-1*(b1*D1+b2*D2-Dm1);

bm1=1-bm2;

b1=t1/(t1+t2);

t1=1-t2;

b2=1-b1;

The parameters that I want extracted from the dataset are D1, D2, t1, t2, b1 and b2. ld and bd are given constants.

One possible solution would be to guess the initial values of the parameters and calculate temporary datasets of Dm1, Dm2, bm1 and bm2. Dataset y would be calculated from the latter datasets and fitted to the experimental points of y. This is done by minimizing the standard deviation between the fit and the experimental y's. The resulting parameters would then be optimized.

I would love to use Origin to do this as I then have access to better algorithms.

I have not started to use Origin C yet, but as I try to use it for the given set of equations I only get a message that it is not possible to compile.

Any help would be appreciated.

Regards,
EJ
easwar Posted - 04/01/2003 : 1:24:01 PM
Hi EJ,

This is definitely possible - the equation for y can in turn have other functions that use the same indep. variables etc.

It is not clear from your message what the equation looks like. Contact your local tech support office more help, or post with more details.

Easwar
OriginLab.


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