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
 Hello

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
stra11an Posted - 05/15/2001 : 03:13:30 AM
Hello,
please help me. This is a problem I can´t solve. I have 30 to 50 graphs in a project and as many data worksheets with four columns. Every graph has only one layer and just one curve. I need a script that that will perform a nonlinear square fit on each graph. First column (x-axes) from the worksheet should be set independent and the fourth column (y-axes) should be dependent. I have a custom buit function with four parameters called A, B, G and n and that works. They need to be initialized to 1,1,200 and 1 respectively.
I tryed numerous combinations with a sample script that should work in principle if someone could fill in the blanks for me i.e. type correct sintax.

doc –e D
{ nlsf.func$=´´name´´;
nlsf.fitData$=????; (it should be 4th col from data worksheet)
nlsf.x$=????; (it should be 1st col from data worksheet)
nlsf.xmode=0:;
nlsf.pn=????; (A=1,B=1,G=200,n=1)
nlsf.wType=2;
nlsf.fit(100);
nlsf.pasteToPlot=1;
clr; };

Thanks in advance.
Strahinja Stojadinovic
Kent State University


Edited by - strahinja on 05/15/2001 03:17:08

Edited by - strahinja on 05/15/2001 03:18:17

Edited by - strahinja on 05/15/2001 03:18:54
4   L A T E S T    R E P L I E S    (Newest First)
rtoomey Posted - 05/17/2001 : 12:30:42 PM
The property, nlsf.pastetoplot, is actually just a switch which tells the fitter whether or not you want the parameters pasted to the plot upon completion of the fit. The parameters don't actually get pasted to the plot until you click the Done button on the Fitting Session page of the fitter. In LabTalk terms, this is the equivalent of executing the nlsf.end() method. To fully implement this, add the following lines to your script:

  1. Add nlsf.begin(); immediately after nlsf.init();.
  2. Add nlsf.end(); immediately prior to the closing curly brace }.


In addition to this, you have two options:



1) You can continue to use nlsf.pastetoplot=1; in your script.

or

2) You can enable the Paste Parameters to Plot check box for that function (inside the fitter) and save the change to the function's definition file. Note: To save a function, select Function:Edit and click the Save button. Saving this change to the function will force the fitter to output its results to the plot for ALL future fits.



Finally, your best bet for viewing the parameters in a worksheet would be to click the Param. Worksheet button on the Results page (Action:Results) in the fitter. To duplicate this action through script, you must use the run.section() method to run the ParaConf section of the file called OFIT.OGS. In doing so, you must also pass the script the worksheet name. Furthermore, since the script loops through all worksheets, you must somehow prevent it from executing when it encounters these parameters worksheets. To do that, I have built in an if statement. See the fully edited version of the script below:





myinc=1;
doc -e W
{
%A=%H; // store active window name
if(%[%A,11]!="Parameters")
{
%B=nlsf.func$;
nlsf.init(); // initialize the fitter
nlsf.begin(); // complement to end()
nlsf.func$=MyLine; // initialize function to be used
nlsf.p1=0.1; // initialize the parameter values
nlsf.p2=0.1;
nlsf.fitData$=%(%A,4); // initialize the dependent dataset
layer -a; // rescale the graph when it comes up
nlsf.wType=2; // statistical weighting
nlsf.fit(100); // 100 iterations
nlsf.xmode=0; // use same X as fit data
run.section(fit.ogs,ParaConf,Parameters$(myinc));
myinc++;
nlsf.end(); // forces After Fit to run
}
};




I hope that all this makes sense. And BTW, I'm a big fan of Japanese food.

stra11an Posted - 05/16/2001 : 4:30:43 PM
There is one problem, however!
nlsf.pasteToPlot=1; doesn't seem to work.
When I typed echo=1; two errors showed
Error:QuitFit and
Error:EndIterate
The fitted curve was pasted to the graph and it looked very nice.
By the way how do I paste parameters into a worksheet?
Thanks.
stra11an Posted - 05/16/2001 : 10:56:15 AM
thanks rtoomey,
it works great, if you ever happen to be in Kent OH, I'll buy you lunch.
Strahinja
rtoomey Posted - 05/15/2001 : 3:58:56 PM

Here's an example script you might consider trying (after amending it):




doc -e W // W is for each worksheet which is what you want to do
{
%A=%H; // store active window name
nlsf.init(); // initialize the fitter
nlsf.func$=MyLine; // initialize the function to be used
nlsf.p1=0.1; // initialize the parameter values
nlsf.p2=0.1;
nlsf.fitData$=%(%A,3); // initialize the dependent dataset
layer -a; // rescale the graph when it comes up
nlsf.wType=2; // statistical weighting
nlsf.fit(100); // 100 iterations
nlsf.xmode=0; // use same X as fit data
%A!wks.col$(%A!wks.ncols).name$="FitData"; // rename fit data column to "FitData"
};



Note 1: Anything in red must be tailored to meet your needs.



Note 2: The function must be defined in the fitter with the Same X as Fitting Data radio button selected in Scripts => After Fit. To get to this window, make sure you are in the "advanced" mode of the fitter. To get to the advanced mode, click the More button. If you don't see a More button (and instead see a Basic Mode button), you are in the advanced mode already.



Note 3: Initializing the parameters using nlsf.pn must be done in the same exact order as they are defined in your function in the Parameter Names text box. In your case, that might be as follows (assuming A,B,G,n is how you ordered the parameter names in the text box):



nlsf.p1=1; // initialize A
nlsf.p2=1; // initialize B
nlsf.p3=200; // initialize G
nlsf.p4=1; // initialize n



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