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 write a long function for fitting?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Meilongwei

China
5 Posts

Posted - 04/15/2015 :  11:47:04 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Dear all:
I have another question.
My function is too long and could be express three short product as follows:
y=A*B*C
A=a1*x+b1^x+x^c1+d1
B=a2*x+b2^x+x^c2+d2
C=a3*x+b3^x+x^c3+d3

Here a1,b1,c1,a2,b2,c2,a3,b3,c3 are parameters I need fit.
I tried with C code form but failed.
How could I write such express?
Is Amanda here?
Thanks!

meilongwei

jasonzhao

China
262 Posts

Posted - 04/16/2015 :  05:21:24 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,


You can refer to this tutorial for more information

http://www.originlab.com/doc/Tutorials/UserDef-FitFunc

The Derived Parameters is used in fitting.


Best regards!
Jason
OriginLab Technical Service
Go to Top of Page

Meilongwei

China
5 Posts

Posted - 04/16/2015 :  12:13:32 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by jasonzhao

Hello,


You can refer to this tutorial for more information

http://www.originlab.com/doc/Tutorials/UserDef-FitFunc

The Derived Parameters is used in fitting.


Best regards!
Jason
OriginLab Technical Service



Hi Jason!
I clicked the link you attached, it just shows how to define general function for fitting. But my function is too long to write in oring C.It should be write as follows:
y=A*B*C+A*B+A*C+A/B+B*C+3A...(more complex than this)
A=a1*x+b1^x+x^c1+d1+exp(x^e1)
B=a2*x+b2^x+x^c2+d2+exp(x^e2)
C=a3*x+b3^x+x^c3+d3+exp(x^e3)

a1, b1,... a2, b2...are parameters need to be fitting. A, B, C are intermediate terms for shorten y expression. I mean during express y, A B C is necessary. So how to write it correctly?
Thank you !

meilongwei
Go to Top of Page

snowli

USA
1386 Posts

Posted - 04/16/2015 :  12:37:28 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

In Fitting Function Builder, you can choose Function Type to be Equation. Then you can split the functions into multiple lines.

But remember to put the final y=..... at the end instead of at the beginning.



The hint on left panel says

---------------------------------------------------------
Function Type
---------------------------------------------------------
Select this option if you need multiple lines or you have more than one dependent variable.

This option does not support control structures such as loops or if-else statements. You can however use the ternary operator.

This option provides faster performance than Origin C.

-------------------- Example1: --------------------

temp = 10;
y1 = A + exp( (x1 - xc) / temp^2 );
y2 = A + temp / (x2 - xc)^2;

-------------------- Example2: --------------------

B = A / (0.5 * (sig1+sig2) * sqrt(2*pi));
sig = ( x<xc ? sig1:sig2 );
y = y0 + B * exp(-0.5 * ((x-xc)/sig)^2);


Thanks, Snow

Edited by - snowli on 04/16/2015 12:42:09 PM
Go to Top of Page

Meilongwei

China
5 Posts

Posted - 04/16/2015 :  10:05:22 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by snowli

Hello,

In Fitting Function Builder, you can choose Function Type to be Equation. Then you can split the functions into multiple lines.

But remember to put the final y=..... at the end instead of at the beginning.



The hint on left panel says

---------------------------------------------------------
Function Type
---------------------------------------------------------
Select this option if you need multiple lines or you have more than one dependent variable.

This option does not support control structures such as loops or if-else statements. You can however use the ternary operator.

This option provides faster performance than Origin C.

-------------------- Example1: --------------------

temp = 10;
y1 = A + exp( (x1 - xc) / temp^2 );
y2 = A + temp / (x2 - xc)^2;

-------------------- Example2: --------------------

B = A / (0.5 * (sig1+sig2) * sqrt(2*pi));
sig = ( x<xc ? sig1:sig2 );
y = y0 + B * exp(-0.5 * ((x-xc)/sig)^2);


Thanks, Snow



Dear SnowLi:
Thanks for your immediate help! It works now!
By the way, I generated too many user-defined functions, how could I delete those functions?

meilongwei
Go to Top of Page

jasonzhao

China
262 Posts

Posted - 04/17/2015 :  03:37:39 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

You can click F9 in Origin interface to open the Fitting Function Organizer, then blowse to User Defined folder left, select the functions unwanted, click remove to delete the items.

please refer to this page for further details.
http://www.originlab.com/doc/Origin-Help/FitFunc-Organizer


Best regards!
Jason
OriginLab Technical Service
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