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
 Define "global" functions like sin, cos, etc.?

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
CPraetorius 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
2   L A T E S T    R E P L I E S    (Newest First)
CPraetorius 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
Hideo Fujii 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

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