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 for Programming
 LabTalk Forum
 nlsf procedure to calculate the baseline

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
zangyef Posted - 03/27/2006 : 05:25:40 AM
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,


4   L A T E S T    R E P L I E S    (Newest First)
zangyef Posted - 04/04/2006 : 11:03:07 AM
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

easwar Posted - 04/03/2006 : 09:07:46 AM
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

zangyef Posted - 04/03/2006 : 06:17:28 AM
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?

easwar Posted - 03/28/2006 : 2:49:51 PM
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


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