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
 two data sets two function fit

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
nnovak Posted - 06/12/2013 : 11:22:49 AM
Origin Ver. and Service Release (Select Help-->About Origin):OriginPro 8
Operating System:WinXp

Hello,
I have problem with fitting simultaneously two data sets with two functions. Let me describe the problem. I have two Y (dependent variables) and one X (independent variables). This is my function for fitting:
P0=0.5;
for (ii=1;ii<=5;ii++)
{
P1=P0-(a*(x-T0)*P0+b*P0^3+c*P0^5+d*P0^7-400000)/(a*(x-T0)+3*b*P0^2+5*c*P0^4+7*d*P0^6);
P0=P1;
};
y_1=1/(a*(x-T0)+3*b*P0^2+5*c*P0^4+7*d*P0^6);

Po0=0.5;
for (ii=1;ii<=5;ii++)
{
Po1=Po0-(a*(x-T0)*2+b*Po0^3+c*Po0^5+d*Po0^7-800000)/(a*(x-T0)+3*b*Po0^2+5*c*Po0^4+7*d*Po0^6);
Po0=Po1;
};
y_2=1/(a*(x-T0)+3*b*Po0^2+5*c*Po0^4+7*d*Po0^6)
The FOR loop is actually Newton method to calculate the value P which is needed to fit y_1 or y_2. Parameters a,b,c,d, and T0 should be the same (parameter sharing). I select NLFit and written function, then I define the data input and the problems starts. I select ''Add all plots on active page'' and ''Global fitting(for sharing)''. I define the column A for X input data under the Rang1 and I have to select y_1, y_2 B and C column. In this moment on graph starts to appear new layers and I have to select the input parameters x column A, y_1,y_2 B,C in Range 2. And of course additional layers appears. Way do I have two ranges and way appears these layers? I have no idea if the code for fitting is correct but it works fine if I fit the data separately (but than the fit parameters are different). I tray also with simple linear function:
y _1= 2*x + A;
y_2=2*x+2*A
I took y_1 and y_2 so that fitted parameter A is 3 in both cases (sharing parameters). And the problem was the same. The layers again appears and I have to select again two ranges. I hope I described the problem well and that someone has a solution for me. Thanks
3   L A T E S T    R E P L I E S    (Newest First)
greg Posted - 06/13/2013 : 11:20:57 AM
If you are only fitting one range, there is no option for global fitting, sharing, etc. because those are only available for multi fits.

Even though your function does two fits it is considered a single function doing a single fit so only one range is needed.

When fitting with such functions, Origin creates Fit Curve previews with two layers - one for each dependendent variable in the fuinction.

You had mentioned global fitting and sharing so I described the process for two ranges. Please be more precise about what you are trying to do.
nnovak Posted - 06/12/2013 : 7:00:06 PM
Hi,
I used Y-script. In old version I think 6.1 is all you need to do if you fit with two functions to assign what is x,y_1 and y_2 (and it was I think only one Range). I understand that I have to select column for input x and columns for y_1 and y_2 but here I chose column A for x and also for y_1 and y_2 (B and C),so columns or data are defined. I do the same for Range 2. The Input data box for range 1 has written Input ''B'' and rang 2 input''C''. But immediately I define the columns for x,y_1,y_2 in range 2 it starts to add new layers???? Why do I have to define y_2 in range 1 and y_1 in range 2? There can be a mistake in the code but I doubt it because the same code works if I do fitting with one set of data. To avoid the problem with code I try with simple two linear fits but I had the same problem. If I do not define all data for range 1 or 2 I can not fit because I get error that the input data are not defined. So please if you can explain again on linear example with three columns (A-x,B-y_1,C-y_2). Thank you.
greg Posted - 06/12/2013 : 3:30:35 PM
Add all plots on active page is not going to work.

That option is not 'smart' enough to recognize that your function has two dependent variables. You need to define one range for each two variables you are fitting. Each range will consist of the x, the y_1 and the y_2, each of which must be assigned to data.
For example: Suppose I plot columns B,C,D and E against A.
Origin will automatically assign the x = A and y_1 = B in Range1, but I have to tell it to use y_2 = C.
Then I can click the flyout next to Input Data and select Add Plot(3): D
which will create a second Range where x = A and y_1 = D and I have to assign y_2 = E.
Then all will be OK.

Incidently, you did not mention that you must have set the Function Form to something other than OriginC, because your function (as written) will not compile in OriginC and needs some variable declarations to work.

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