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
 Simulation vs Fitting- Error bars

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
anildsx Posted - 10/04/2006 : 06:11:25 AM
Hi,

I have created a new (user-defined) Non-Linear Curve Fit function to fit my experimental values. In the equation used for fitting, I have some known values (defined as constants) and some unknown (variable). To get the guess values for the unknown, I am using MathCAD and use those guess values in Origin to fit the data. The simulation on my experimental data (in MathCAD) looks good, but as soon as I use simulated values (for unknown) in Origin in the defined function, the fit goes crazy and comes up with huge error-bars. There is no compilation error, so I assume the user-defined function is working well.

Thanks in advance!

The equations in Mathcad used for fitting is uploaded as a doc file and the origin script (main text) used is shown below,


Origin Script I wrote:



int i,
np,
maxq;

double ytemp,
term1Q,
term2Q,
D1Q,
D2Q,
P1Q,
P2Q,
EQ;

np=10; //number of points
maxq=6*10^4;

ytemp = 0;

for (i=0; i<=10; i+=1)
{
qi = 0.01 + (maxq/np)*i;

if (qi=Q)
{
term1Q = Df+Db+(1/(2.0*pi*Q)^2)*((1/tauf)+(1/taub));
term2Q = sqrt(((Db-Df+(1/(2.0*pi*Q)^2))*((1/taub)-(1/tauf)))^2+4.0/(((2.0*pi*Q)^2)^2*tauf*taub));
D1Q = 0.5*(term1Q-term2Q);
D2Q = 0.5*(term1Q+term2Q);
P2Q = (Pb*Db+Pf*Df-D1Q)/(D2Q-D1Q);
P1Q = 1-P2Q;
EQ = P1Q*exp(-(2.0*pi*Q)^2*D1Q*bigd)+P2Q*exp(-(2.0*pi*Q)^2*D2Q*bigd);
}
ytemp = EQ;
};

E= ytemp*1;


4   L A T E S T    R E P L I E S    (Newest First)
anildsx Posted - 10/06/2006 : 01:11:11 AM
Thanks Mike, now I sorted it out!

Mike Buess Posted - 10/05/2006 : 07:56:12 AM
Also works in Origin... printf("%d: EQ=%f, Q=%f\n",i,EQ,Q)

But I don't see how the code you presented changes Q. Isn't Q the independent variable for fitting and E the dependent?

Mike Buess
Origin WebRing Member
anildsx Posted - 10/05/2006 : 05:00:04 AM
Sorry I have to refine my question now!

How do I programme in Origin to get each value of EQ for every increment 'i'(which changes the value of Q)?

I mean in C-programme, at the end of 'for' loop I can include

printf("%lf",EQ);
printf("%lf",Q);

to get EQ for each value of Q. Is there a way to do the same in Origin?


Mike Buess Posted - 10/04/2006 : 08:04:46 AM
The only mistake I see is the if condition, which should be qi==Q. Your function will compile and run with a single equal sign but will surely give the wrong result.

Mike Buess
Origin WebRing Member

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