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
 Fitting function

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
Sumeet kumar Posted - 06/23/2019 : 10:01:56 AM
I am trying to fit data to a function having six parameters and a constant. I entered the values of the constant and parameters to check whether the function is working or not. But I got different values from the function from Origin than from Matlab. I have attached Matlab code below in which in the lower comment, I directly copied and pasted the function written in Origin.

clear; clc;

n2 = 3;
k2 = 0.1;
n3 = 4;
k3 = 2.5;
kp = 1e-18;
t0 = 600;

lam = 1.625e-6;
t = 0;

y = 1 - abs((((1-n2)+i*k2)*((n2+n3)-i*(k2+k3))+((n2-n3)-i*(k2-k3))*((1+n2)-i*k2) ...
*exp(4*pi*sqrt(kp*(t+t0))*(-k2-i*n2)/lam))/(((1+n2)-i*k2)*((n2+n3) ...
-i*(k2+k3))+((1-n2)+i*k2)*((n2-n3)-i*(k2-k3))*exp(4*pi*sqrt(kp*(t+t0))*(-k2-i*n2)/lam)))^2

%y = 1 - abs( ( ( ( 1 - n2 ) + 1i * k2 ) * ( ( n2 + n3 ) - 1i * ( k2 + k3 ) ) + ( ( n2 - n3 ) - 1i * ( k2 - k3 ) ) * ( ( 1 + n2 ) - 1i * k2 ) * exp( 4 * pi * sqrt( kp * ( t + t0 ) ) * ( -k2 - 1i * n2 ) / lam ) ) / ( ( ( 1 + n2 ) - 1i * k2 ) * ( ( n2 + n3 ) - 1i * ( k2 + k3 ) ) + ( ( 1 - n2 ) + 1i * k2 ) * ( ( n2 - n3 ) - 1i * ( k2 - k3 ) ) * exp( 4 * pi * sqrt( kp * ( t + t0 ) ) * ( -k2 - 1i * n2 ) / lam ) ) )^2

Thanks all
2   L A T E S T    R E P L I E S    (Newest First)
Sumeet kumar Posted - 06/25/2019 : 06:15:26 AM
Thanks for the reply.

I got a mail from the technical team of Origin in which following suggestions were given.

If you write the fitting function in LabTalk, please use "imabs" instead of "abs", "imexp" instead of "exp".

If you write the function in OriginC, please use "cabs" instead of "abs". "exp" can work for complex number in OC.


When I implemented those changes, then it is working fine.
Castiel Posted - 06/23/2019 : 10:24:42 PM
quote:
Originally posted by Sumeet kumar

I am trying to fit data to a function having six parameters and a constant. I entered the values of the constant and parameters to check whether the function is working or not. But I got different values from the function from Origin than from Matlab. I have attached Matlab code below in which in the lower comment, I directly copied and pasted the function written in Origin.

clear; clc;

n2 = 3;
k2 = 0.1;
n3 = 4;
k3 = 2.5;
kp = 1e-18;
t0 = 600;

lam = 1.625e-6;
t = 0;

y = 1 - abs((((1-n2)+i*k2)*((n2+n3)-i*(k2+k3))+((n2-n3)-i*(k2-k3))*((1+n2)-i*k2) ...
*exp(4*pi*sqrt(kp*(t+t0))*(-k2-i*n2)/lam))/(((1+n2)-i*k2)*((n2+n3) ...
-i*(k2+k3))+((1-n2)+i*k2)*((n2-n3)-i*(k2-k3))*exp(4*pi*sqrt(kp*(t+t0))*(-k2-i*n2)/lam)))^2

%y = 1 - abs( ( ( ( 1 - n2 ) + 1i * k2 ) * ( ( n2 + n3 ) - 1i * ( k2 + k3 ) ) + ( ( n2 - n3 ) - 1i * ( k2 - k3 ) ) * ( ( 1 + n2 ) - 1i * k2 ) * exp( 4 * pi * sqrt( kp * ( t + t0 ) ) * ( -k2 - 1i * n2 ) / lam ) ) / ( ( ( 1 + n2 ) - 1i * k2 ) * ( ( n2 + n3 ) - 1i * ( k2 + k3 ) ) + ( ( 1 - n2 ) + 1i * k2 ) * ( ( n2 - n3 ) - 1i * ( k2 - k3 ) ) * exp( 4 * pi * sqrt( kp * ( t + t0 ) ) * ( -k2 - 1i * n2 ) / lam ) ) )^2

Thanks all


abs, exp, sqrt etc. does not support complex number in Origin.
You can handle the real part and the imaginary part separately.


                                          &&&&&&&&&
                                        &&&
                                       &&
                                      &  _____ ___________
                                     II__|[] | |   I I   |
                                    |        |_|_  I I  _|
                                   < OO----OOO   OO---OO
**********************************************************

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