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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Bringing back two fits in a worksheet
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

vion

France
Posts

Posted - 02/23/2007 :  03:47:56 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5
Operating System: XP Pro SP2

I fit a complex function, that is, two dependent variables ReV and ImV that depend on one independent variable f. The data are in 3 columns Data1_f,Data1_ReV and Data1_ImV of a worksheet Data1. The worsheet has already two other columns ReFit and ImFit for bringing back the resulting datasets to be created by the NLSF.

I try to bring back the results using the following "after script":

nlsf.xmode=0;
nlsf.funccol$=Data1_ReFit;
nlsf.makecurve(func);

It does not really works since I get the first fit in the proper column ReFit as expected, nothing in the ImFit one, and then two new columns are created at the end of the worsheet with the two fits.

What should I do.

Thank you !!!

Denis

Mike Buess

USA
3037 Posts

Posted - 02/23/2007 :  4:14:49 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Denis,

Since nlsf has only one funccol$ property it doesn't look like you can create two fit curves with nlsf.makecurve(). On the other hand, you appear to be getting both fit curves in new columns at the end of your worksheet. I suspect that your fitter's After Fitting page looks like that shown below and the columns at the end of the worksheet are created by your Fit Curve options at the top. (Since X is same as that of the original data those columns are added to same worksheet.) So your After Fitting Scripts, as well as the ReFit and ImFit columns, are not needed because the same thing is already achieved by your Fit Curve options.



Mike Buess
Origin WebRing Member
Go to Top of Page

Laurie

USA
404 Posts

Posted - 02/23/2007 :  5:08:22 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Denis,

Let's take the example where I fit a user defined equation defined as follows:
y_1=P1+P2*x;
y_2=P2*x^2;

You have two choices for script to use in the After Fitting Script:

Option1:
%A=%[%C,'_'];
%B=xof(%C);
%A_ReFit = P1 + (P2 * %B);
%A_ImFit = P2 * %B^2;

This option calculates the values, using the equation and the parameter values found while fitting. %A stores name of worksheet and %B stores name of X dataset.

Option2:
%A=%[%C,'_'];
%A!wks.col$(%A!wks.ncols-1).name$=ReFit;
%A!wks.col$(%A!wks.ncols).name$=ImFit;

This option simply renames the two columns that the fitter automatically adds (when you have "Same X as Fitting Data" chosen). This might be the easier option since the columns don't have to already exist in the worksheet, and you can just copy and paste the script above for option 2 as is. Option 1 requires you to replace the equations used in this example with your actual equations.

Laurie

OriginLab Technical Support
Go to Top of Page

vion

France
Posts

Posted - 03/06/2007 :  06:26:18 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks a lot Mike and Laurie,

Actually, I cant't solve my problem with the mehtods you suggest.
Indeed, I need to have the selected columns already created because they are used to calculate other columns (in auto-update mode), which are plotted in a graph that is also to be updated automatically after each fitting session. Moreover, I can't recalculate the functions from the fitting parameters in Labtalk (as suggested by Laurie in method 1) because the calculation involve a compiled function in Origin C that involves complex numbers.
I just need to copy the two resulting fitting functions in my ReFit and ImFit columns. It should be possible since the corresponding datasets exist somewhere in origin. They are for instance displayed in the graph window on top of the experimental data.

Denis




Denis
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 03/06/2007 :  09:13:03 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Indeed, I need to have the selected columns already created because they are used to calculate other columns (in auto-update mode), which are plotted in a graph that is also to be updated automatically after each fitting session.
Why not do your calculations in the After Fit Scripts instead of Set Column Values?
quote:
Moreover, I can't recalculate the functions from the fitting parameters in Labtalk (as suggested by Laurie in method 1) because the calculation involve a compiled function in Origin C that involves complex numbers.
I don't understand because that's exactly what the fitter does when it calculates the fit curves. I hope you don't think that Origin's columns can be complex... they can only contain real data. However, if you really need to copy the fits to existing columns it can be done with this After Fit script.

Option3:
%A=%[%C,'_'];
%A_ReFit=%(%A,wks.ncols-1);
%A_ImFit=%(%A,wks.ncols);

Like Laurie's Option2 that assumes that the fitter is automatically calculating the fit curves. I stress that this will give the same results as Laurie's Options 1 and 2.

Mike Buess
Origin WebRing Member
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000