T O P I C R E V I E W |
punktrocker |
Posted - 08/30/2017 : 10:50:15 AM Hello everybody, I´m trying to use my user defined Fitting function written in OriginC in a Labtalk script. I added #pragma labtalk(1) in the ".fit" files and the function appears when i write "list f;" in the command window.
My Problem is when i want to use the Fitting like it works in the NLfitting Dialog Box in my Labtalk script, i Need to call the Parameter initialisation first "_nlp....fit" and this funtions wants a curve type variable which doesn´t exist in Labtalk as far a i know.
code of my "_nlsf...fit" " #pragma numlittype(push, TRUE) #pragma numlittype(push, TRUE) #pragma warning(error : 15618) #include <origin.h> #pragma labtalk(1)
void _nlsfGlassTransition_Linear( // Fit Parameter(s): double x1, double y1, double x2, double y2, double x3, double y3, // Independent Variable(s): double x, // Dependent Variable(s): double& y) { // Beginning of editable part if (x< x3) y=(y1*(x3-x)+y3*(x-x1))/(x3-x1); else y=(y3*(x2-x)+y2*(x-x3))/(x2-x3); // End of editable part }
"
code of my "_nlp...fit"
" #pragma numlittype(push, TRUE) #pragma numlittype(push, TRUE) #pragma numlittype(push, TRUE) #include <origin.h> #pragma labtalk(1)
void _nlsfParamGlassTransition_Linear( // Fit Parameter(s): double& x1, double& y1, double& x2, double& y2, double& x3, double& y3, // Independent Dataset(s): vector& x_data, // Dependent Dataset(s): vector& y_data, // Curve(s): Curve x_y_curve, // Auxilary error code: int& nErr) { // Beginning of editable part int n1,n2,n3; x_data.GetMinMax( x1, x2, &n1, &n2 ); x3 = x1 + (x2 - x1)/2; y1= y_data[n1]; y2=y_data[n2]; vector vd; vd = abs (x_data - x3); double xta, xtb; vd.GetMinMax( xta, xtb, &n3); y3= y_data[n3]; //Code to be executed to initialize parameters // End of editable part } " and that is what i tried in my command window:
double xx1 = wcol(1)[1]; double yy1 = wcol(2)[1];
double xx2 = wcol(1)[21]; double yy2 = wcol(2)[21];
double xx3 = wcol(1)[11]; double yy3 = wcol(2)[11];
range xx = wcol(1); range yy = wcol(2); double xxi=xx; double yyi=yy;
_nlsfGlassTransition_Linear(xx1, yy1, xx2, yy2, xx3, yy3, xxi, yyi);
There are no Errors but also no Output but i don´t know what is missing. The Goal is to have a script where i can fit all Graphs in an active Folder and then extract the Fitting data ("x3") into a new workbook.
thanks a lot
punktrocker
|
8 L A T E S T R E P L I E S (Newest First) |
punktrocker |
Posted - 09/06/2017 : 08:32:41 AM Hi, Ty again for this Information. Ist somehow hard to find the right Pages in this Origin Help.
My next question is about the nltree Treenode. I want some of my Parameters which are automatically initialized to be fixxed. i foound that i can achieve that with nltree.fn but i can t figure out where this has to be placed that it works. |
yuki_wu |
Posted - 09/05/2017 : 06:06:32 AM Hi,
Please take a look at this knowledge base item and see if this applies to you: http://www.originlab.com/doc/LabTalk/guide/Range-Notation#Worksheet_DataRange.2C_Worksheet_Data
Hope it helps.
Regards, Yuki OriginLab
|
punktrocker |
Posted - 09/05/2017 : 04:30:25 AM i Loop over all wks in 1 book and i want to plot the Fits from another book in the same graph. So i wanted to Loop over 1 book and then Access the important Sheets of the fit book to plot the fit in the same layer. I tried to use a range over the other workbook, but i can´t find an example how i can Access the "fitbook"-worksheets and the "fitbook"-Columns saved in the range of the book.
range aa =[book1];
aa.sheet1.col1=; ?????? is it working somehow like that? I haven´t found any example doing this somehow. I found a lot of how to define it but not how to Access the Sheets and rows of a book range. |
yuki_wu |
Posted - 09/04/2017 : 11:02:33 PM Hi,
We have an example about fitting multiple columns that may help: http://www.originlab.com/doc/LabTalk/examples/Curve-Fitting#Fit_Multiple_Columns_in_a_Worksheet
I suppose you are using “doc -e LW” to loop over all layers in the current workbook, which means that you switch worksheet in each iteration. So what is your real question?
Regards, Yuki OriginLab
|
punktrocker |
Posted - 09/04/2017 : 08:40:06 AM Hi again, my next Problem:
"nlbegin iy:=(1,%(varPLOT$),(%(varPLOT$)+1))func:=GlassTransition_Linear nltree:=ParamTree weight:=ins;"
i want to do multiple fits from different columns, so i tried to use a variable but how can i do things like that "iy:=(1,%(varPLOT$),(%(varPLOT$)+1))" in Labtalk? so adding 1 to the column number to get the weights ? I tried also %(varPLOT$)+%("1) .. hasn´ worked. Is this possible at all in Labtalk?
another Problem is here. i want to Switch between worksheets in a plotting Loop with an integer variable but i can t figure out the right Syntax for that. Here the example code:
worksheet -b %(PlotBook$); page.active=1; int l=3;
doc -e LW { plotxy iy:=(1,%(varPLOT$)) plot:=201; plotxy iy:=[bkname$]%(l)!(1,2) plot:=200 ogl:=!1; if(varPLOT$==2) { page.label$= %(1,@WL)_%(1,@Ws)_index; } else { page.label$ = %(1,@WL)_%(1,@Ws)_absorbtion; } l=l+2; }
|
yuki_wu |
Posted - 08/31/2017 : 11:16:55 PM Hi punktrocker,
We can use nlend X-Function ends the fitting session with a report sheet
nlend output:=1; So you will get the fit data in FitNLCurve1 sheet at last.
At the beginning of this page, which I mentioned in the previous post, it introduces some X-Functions of nonlinear fitting: http://www.originlab.com/doc/LabTalk/guide/Non-linear-Fitting
Regards, Yuki OriginLab
|
punktrocker |
Posted - 08/31/2017 : 09:20:28 AM hi yuki_wu, ok i haven´t found this so far thank you this helped me a little bit. My Problem now is that the fit works but how can i save the data into a new sheet in a new workbook and then plot it into a layer of an inaktive already existing graph? :-)Problem is the plotting cause i don t know where the fit data is stored.
thanks a lot
punktrocker |
yuki_wu |
Posted - 08/31/2017 : 02:11:14 AM Hi punktrocker,
Are you trying to perform nonlinear fitting with a user-defined fitting function by LabTalk?
Would you please have a look at this knowledge base item and see if this applies to you: http://www.originlab.com/doc/LabTalk/guide/Non-linear-Fitting http://www.originlab.com/doc/LabTalk/examples/Curve-Fitting#Nonlinear_Fit
Regards, Yuki OriginLab
|
|
|