Author |
Topic |
|
Pattrium
Germany
3 Posts |
Posted - 04/23/2021 : 6:14:46 PM
|
Hello there,
I was trying to make a fitting function containing two integrals using the Fitting Function Organizer. I did it according to the Origin tutorial (https://www.originlab.com/doc/Tutorials/Fitting-2Integral-LabTalk), but with my own function, and it only gives me some weird linear result that makes no sense.
In order to check, if there is a problem with my function, I simplified it to one integral. I already had made a function of the function form expression with the exact same expression and it works.
The function is:
y = pi*L*integral(gaussianR, R0-6*e*R0, R0+6*e*R0,dp ,x ,e ,R0)+b*x
with (LabTalk Functions Definition and Initialization)
function double gaussianR(double R, double dp, double x, double e, double R0) { return (((sqrt(ln(2)))/(sqrt(pi)*e*R0))*exp(-4*ln(2)*((R-R0)/(2*e*R0))^2))*(((R^2)*pi*dp*((2*J1(x*R))/(x*R)))^2) ; }
Parameters etc. are set properly to work with the expression function form.
Problem: once I switch to Equations as function form, the fit/simulation no longer works. Unfortunately I do need the Equations setting in order to have two integrals.
Does anyone know or have an idea, what happens there?
Again: it works on "Expression" and does not, once I simply switch to "Equations".
Thanks for your time and have a great day, Patrick
Origin Ver. and Service Release (Select Help-->About Origin): Origin 2020 (64-bit) SR1 9.7.0.188 (Academic)
Operating System: Windows 10 |
|
Shirley_GZ
China
Posts |
Posted - 04/26/2021 : 03:35:34 AM
|
Hi Patrick,
When you switch to Equation, you need add "y=" before the expression you defined, such as
y = pi*L*integral(gaussianR, R0-6*e*R0, R0+6*e*R0,dp ,x ,e ,R0)+b*x;
Please let me know if any problem.
Thanks, Shirley OriginLab
Originlab Technical Service Team |
|
|
Pattrium
Germany
3 Posts |
Posted - 04/26/2021 : 4:05:03 PM
|
Hi Shirley,
thanks for the response. I did add the "y=" and it didn't work right away but at some point it started working. I have no clue why it happened, though. Anyways, I got the function with only one integral to work on "equations" mode, but not the one with two.
It seems quite inconsistent to me. Probably I am doing something wrong, but I cannot find any mistake.
Here is another one with only one integral:
Parameter names: L,dp,b,R Function: y=((abs(integral(OrientationAverage, 0, pi/2, dp, x, R, L)))^2)+b*x LabTalk functions definition and initialization: function double OrientationAverage(double o, double L, double R, double dp, double x) { return (4*pi*L*(R^2)*dp*((sin(x*L*cos(o)))/(x*L*cos(o)))*((J1(x*R*sin(o)))/(x*R*sin(o)))*sin(o)) ; } As it stands, it gives me nothing at all on "expression" mode and the same odd linear fit on "equations" mode. I checked all brackets and also couldn't find any other mistake.
I am kind of lost here, as I don't know, what the problem is. (for checking I keep the parameters fixed with reasonable values)
I would appreciate any hint leading to the solution of the problem.
Thanks, Patrick
quote: Originally posted by Shirley_GZ
Hi Patrick,
When you switch to Equation, you need add "y=" before the expression you defined, such as
y = pi*L*integral(gaussianR, R0-6*e*R0, R0+6*e*R0,dp ,x ,e ,R0)+b*x;
Please let me know if any problem.
Thanks, Shirley OriginLab
Originlab Technical Service Team
|
|
|
Shirley_GZ
China
Posts |
Posted - 04/27/2021 : 01:45:02 AM
|
Hi Patrick,
Our expert found that the order of parameters in the function calling is not consistent with the order of parameters in the function definition.
Would you please try to fix it? If still problem, please send us the FDF file, https://www.originlab.com/index.aspx?go=Support/SendFilestoSupport
Thanks, Shirley OriginLab
Originlab Technical Service Team |
|
|
Pattrium
Germany
3 Posts |
Posted - 04/27/2021 : 06:12:13 AM
|
Hi Shirley,
thanks a lot! It worked. I was not aware that the order of parameters matters.
Best, Patrick |
|
|
|
Topic |
|
|
|