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
 Forum for Origin C
 Fitting function for drying

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
Dr.S Posted - 01/07/2019 : 08:24:42 AM
Dear all,

I am not too familiar with origin C but i tried my best in order to fit some data with a sum function based on cranks laws of diffusion.

I would like to fit the following function to my data:

y = M (1-8/pi²*SUM(1/(2n+1)² * e^(-(2n+1)²*pi²*D*x/h²) )

where the SUM is the Sum operator with n=0 to n =xx (fixed value, tried it with 5).
In order to fit the function, I programmed the following function:

--------------------------------------

#pragma numlittype(push, TRUE)
#pragma warning(error : 15618)
#include <origin.h>

// Add your special include files here.
// For example, if you want to fit with functions from the NAG library,
// add the header file for the NAG functions here.

// Add code here for other Origin C functions that you want to define in this file,
// and access in your fitting function.

// You can access C functions defined in other files, if those files are loaded and compiled
// in your workspace, and the functions have been prototyped in a header file that you have
// included above.

// You can access NLSF object methods and properties directly in your function code.

// You should follow C-language syntax in defining your function.
// For instance, if your parameter name is P1, you cannot use p1 in your function code.
// When using fractions, remember that integer division such as 1/2 is equal to 0, and not 0.5
// Use 0.5 or 1/2.0 to get the correct value.

// For more information and examples, please refer to the "User-Defined Fitting Function"
// section of the Origin Help file.

//----------------------------------------------------------
//
void _nlsfSUM_Drying(
// Fit Parameter(s):
double D,
// Independent Variable(s):
double x,
// Dependent Variable(s):
double& y)
{
const double M=10410;
const double h=0.0015;
const double p=3.14159;
const double n=5;
// Beginning of editable part


double bb = 0;
for(int ii =1; ii<=n; ii++)
{
bb = (1/(2 * ii + 1)^2) * exp(- (2 * ii +1)^2 * p^2 * D * x / h^2 + bb);
}
y = M *(8/p^2)* bb;
// End of editable part
}

------------------------------------------------

however, fitting does not work and when I try out the function with a fixed value, the result is always 0.
Is there someone who can help me fixing it and make it work?
Thank you very much for your help.

Best regards,
Stefan



1   L A T E S T    R E P L I E S    (Newest First)
yuki_wu Posted - 01/07/2019 : 9:40:20 PM
Hi Stefan,

It seems that you made some mistakes when you wrote the function in the code, for example:

y = M *(8/p^2)* bb;

“1-” is missing.

You need to double check your code.

Regards,
Yuki

OriginLab

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