Author |
Topic |
|
CPraetorius
Germany
2 Posts |
Posted - 05/24/2012 : 08:53:32 AM
|
Origin Ver. and Service Release: 8.6 SR3 64 bit Operating System: Win 7 64 bit
I have a quite complicated model function which I would like to use in the NLS-Fitter or the "set column values" environment in an easy way such as I can use basic functions like sin, cos, exp or Gauss. I want to avoid typing the expression three or more times when defining new fit functions. Is this possible and if yes, how do I define and adress such a function?
example:
definition of "global" function: myfunction(x,par1,par2,par3)=complicated expression
Fit function, variable x, Parameters A,B,par1-6: y=A*myfunction(x,par1,par2,par3)+B*myfunction(x,par4,par5,par6)
Thanks in advance, Christian |
|
Hideo Fujii
USA
1582 Posts |
Posted - 05/24/2012 : 2:21:03 PM
|
Hi Christian,
You can implement a math function in OriginC (which is of course portable), and call it anywhere not only in your user-defined function, but also other places such as in Set Column Values tool.
Let me exemplify by defining a simple math function y=a*x+b as an OC function (using Code Builder), then define a fit function (using Fit Function Builder) which calls the OC function in the formula:
1) Open Code Builder("View: Code Builder" menu). In CB, choose "File: New" menu, and code your desired function (in my sample "mylinear"). Compile ("Tools: Build" menu), and make sure no error there. As in my sample, I also suggest that you include #pragma directive so that you can show this function in the function list in Set Column Value tool (under "F(X)" menu in the dialog; then in my case, under "Math" subcategory). See the explanation at: http://www.originlab.com/www/helponline/Origin/en/UserGuide/Create_a_User_Defined_Function_for_Set_Column_Values.html
(Then, you can drag-and-drop your C source file ("mylinear.c" in my sample) into the System workspace(folder) so that your code would become always available even in other Origin session.)
2) Now you can define your fitting function, which contains your math function defined at 1). Open "Tools: Fitting Function Builder" menu to open it. You can define your function (in my sample "mylinearfit") which contains the previously created OC function as a part. PLEASE NOTE that you define this fit function as "LabTalk Script" in Function Type. By some reason, Expression or Equation doesn't work. I am going to let our developers know.)
You enter your fit function formula in the "Function Body" box in the next next Builder's page. Once you finish the Builder, your fitting function should be ready to use.
Hope the above explanation is clear for you.
--Hideo Fujii OriginLab
|
|
|
CPraetorius
Germany
2 Posts |
Posted - 05/25/2012 : 10:27:27 AM
|
Hi Hideo Fujii,
Thank you very much for the detailed explanation! This totally answers my question. The Origin C workspace is something I wasn't aware of.. It seems to be very useful
kind regards, Christian |
|
|
|
Topic |
|
|
|