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
 Fit won't execute
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ChristophPreis

1 Posts

Posted - 04/25/2010 :  11:12:45 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 8.0724 and Service Release 0 (Select Help-->About Origin):
Operating System: Windows7.

Hello,

I am trying to write a labTalk Script. The supposed to find the baseline of some data, substract the baseline, smooth the points and finally make a gauss fit of the point. Until smoothing everything works fine, but the gauss fit just won't execute. What am I making wrong? Script below.

Thanks in advance!

// Filename: Custom.ogs
// Purpose: The Custom Routine button on the standard toolbar will use this code, by calling
// the [Main] section
// Modifications:


////////////////////////////////////////////////////////////////////////////////
// Main Code
////////////////////////////////////////////////////////////////////////////////
[Main]

//X und Y setzen
for(int jj = wks.ncols-2; jj> 0; jj -= 3){
wks.name$ = DataSheet;
wks.col$(jj).type = 4;
wks.col$(jj+1).type = 1;
wks.col$(jj+2).type = 1;
}


// Minima finden & Untergrund lschen
for(int jj = wks.ncols; jj> 0; jj -= 3){

int rowMinLinks = 1000000;
int rowMinRechts = 1000000;
int xMinLinks = 0;
int xMinRechts = 1000;
for(int ii = 1; ii<100; ii+=1){
if(wcol(jj)[ii] < rowMinLinks){
rowMinLinks = wcol(jj)[ii];
xMinLinks = ii;
}
}
for(int ii = wks.nrows; ii>(wks.nrows-100); ii-=1){
if(wcol(jj)[ii] < rowMinRechts){
rowMinRechts = wcol(jj)[ii];
xMinRechts = ii;
}
}
for(int ii = wks.nrows; ii>0; ii-=1){
wcol(jj)[ii] = wcol(jj)[ii]-rowMinLinks+(rowMinLinks-rowMinRechts)/(xMinRechts-xMinLinks)*(ii-xMinLinks);
}

}

//smoothing
for(int jj = wks.ncols; jj> 0; jj -= 3){

smooth iy:=$(jj) method:=PF percent:=55 oy:=$(jj-1);
smooth iy:=$(jj-1) method:=SG npts:=10 oy:=$(jj-1);

}


//peak fit
for(int jj = [Book1]DataSheet!wks.ncols; jj> 0; jj -= 3){

nlbegin iy:=(1,2) func:=gauss nltree:=MyTree;
// Now fit
nlfit;
// and report results
(Book1, jj, 1) = $(mytree.xc);
type Baseline y0 is $(mytree.y0), Peak Center is $(mytree.xc), Width is $(mytree.w), Area is $(mytree.A);
// end the fitting session without a Report Sheet
nlend 1 1;



}

Penn

China
644 Posts

Posted - 04/27/2010 :  01:32:02 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Please note that the X-Function nlbegin is available since Origin 8 SR2. So the gauss fit can not be executed in Origin 8 SR0. Please update to Origin 8 SR6 according to this page. Also, you should make a little change in your fitting script.

1>(Book1, jj, 1) = $(mytree.xc);
The % sign is needed before (Book1, jj, 1), so it should change to: %(Book1, jj, 1) = $(mytree.xc);

2>nlend 1 1;
To terminate a fit session without output report, the usage is: nlend 0;
For more information about this X-Function, please refer to nlend.

By the way, currently, the latest version is Origin 8.1 SR2, you can download a demo version to have a try as well.

Penn
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