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 for Programming
 LabTalk Forum
 nlsf procedure to calculate the baseline
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

zangyef

Italy
Posts

Posted - 03/27/2006 :  05:25:40 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version : 6
Operating System: WinXP HE

Hi everyone,
I have a problem with a fitting session using LabTalk.
I have to subtract a baseline (calculated with the NLSF procedure) from a graph. The data range used in the fitting session is a limited range of the whole dataset. The script store the best parameters found and use them to calculate the baseline (for the whole dataset) in a column added to the worksheet. The problem is that I want to use X column of the original graph as indipendent variable for the baseline calculation but the script use only the value in the range used to calculate the fit.
Here is the script:

nlsf.Begin();
nlsf.Init();
nlsf.Func$="Log3P1";
nlsf.PasteToLog=0;
nlsf.PasteToPlot=2;
nlsf.fitData$="originaldata_B";
nlsf.p1=40;
nlsf.p2=-4;
nlsf.p3=300;
nlsf.v1=1;
nlsf.v2=1;
nlsf.v3=1;
nlsf.Iterate(100);
nlsf.funcx$="originaldata_A";
nlsf.xBegin=1;
nlsf.xEnd=originaldata!wks.nRows;
nlsf.xPoints = 1 + (nlsf.xEnd)-(nlsf.xBegin);
nlsf.xMode=2;
nlsf.makecurve(func);
nlsf.End();
nlsf.unInit();

originaldata!wks.addcol(F);
originaldata!wks.col6.label$="baseline";
copy NLSF1_B originaldata_F;
window -c NLSF1;
originaldata!wks.addcol(G);
originaldata!wks.col7.label$="correct volume";
originaldata_G= originaldata_B - originaldata_F - 2.5;


Anyone can tell me if there is a way to use the entire x column of the fitting range session for the calculation of the baseline?
Thank you for every suggestion,


easwar

USA
1965 Posts

Posted - 03/28/2006 :  2:49:51 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

There should be a way to do this using nlsf object properties...

But here is a quick, alternate solution:
Say your x values are in col(1) and the raw data is in col(2) and you have added a third empty column that should hold the fit curve for the entire range as you desire (your col positions could be different)

At the end of the fitting script, after nlsf fitting is done, add the following line:
col(3)=fit(col(1));

What the fit() function does is to compute the value of the fit curve for specified x, using the current fit parameters. So as long as fit has converged and ended, this function provides a quick way to get fit curve value for any x. In the above case, it then fills col 3 with fit values for all entries in col 1.

Hope this helps.

Easwar
OriginLab

Go to Top of Page

zangyef

Italy
Posts

Posted - 04/03/2006 :  06:17:28 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you Easwar,
sorry for the late.
I tried to add

originaldata_F=fit(originaldata_A);

to my script but it only fits the range used for the fitting session. I tried to insert the line code in different part of the script but with the same results. So I tried another way. I wrote the function used for the fitting session, using the fit parameter p1, p2 and p3 but it seems origin descard the value obtained from the fitting session just when calculated.
Maybe it is a simple problem with a simple solution...but I'm not able to solve it at the moment!
Any suggestion?

Go to Top of Page

easwar

USA
1965 Posts

Posted - 04/03/2006 :  09:07:46 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi zangyef,

How are you restricting the range of data to fit? Using data markers, or by setting rows as begin and end on the worksheet? If settting begin and end rows, you need to rest to full range and then use the fit() function.

I suggest you contact tech support and send them your data/OPJ and the script and the steps you follow so they can resolve this and get back to you.

Easwar
OriginLab

Go to Top of Page

zangyef

Italy
Posts

Posted - 04/04/2006 :  11:03:07 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Ok, I contacted the Origin Tech Support and they give me the solution. The problem is that Origin remember the range used in the nlsf procedure and don't descard the mks variables value. So, to make it possible to calculate the baseline for the whole dataset is necessary reset the range. To do this this is the code:

mks1=1; // to set the beginning index of the range to 1
limit Data1_B; // to get the number of rows
mks2=limit.size; // to set the end index of the range to the end of the
dataset

Hope this help someone else.
Bye

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