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
 How to output nlfit results into source sheet?

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
yyyhhh Posted - 09/16/2014 : 02:34:36 AM
Origin Ver.9.0 and Service Release 2 (Select Help-->About Origin):
Operating System: Win 8.1

Hi,
I want to output results of nonlinear fitting into the source work sheet. The results are outputted into a new sheet in default setting.
I thought that the value of nlgui's treenode defines the destination of output. So I tried some codes like below. But nothing works.

could someone give me an advice?

Thank you

nlbegin iy:=(col(a),col(c)) func:=gaussian;
nlfit;
nlgui gg 1;
gg.Output.Data.Sheet :=<source>;
nlgui gg 0;
gg.=;
nlend 1
15   L A T E S T    R E P L I E S    (Newest First)
SeanMao Posted - 05/12/2015 : 9:45:40 PM
Hi,

The R^2 you mentioned corresponds to Adjusted R-square in Origin which optimizes R^2 in the case of poor fit, adding variables, etc.

Read this page for more details about R^2 and adjusted R^2:

http://www.originlab.com/doc/Origin-Help/Interpret-Regression-Result


The command is:


$(FitRes.adjr)


Regards!

Sean
marasneo Posted - 05/12/2015 : 06:42:19 AM
Thank You Sean!!
Almost everything is ok now.

I have probably (hope so) the last problem.
I am trying to extract also R^2 - how to do that?
SeanMao Posted - 05/12/2015 : 02:19:33 AM
Hi,

To activate a sheet, use the following commands:


win -a Test; // Activate workbook Test;
page.active$ = Test; // Activate worksheet Test;
wcol(1)[1] = $(FitRes.t1);


Regards!

Sean

quote:
Originally posted by marasneo

Ok,
I am trying with this:
getnlr iw:=__REPORT$ tr:=FitRes pn:=1; type y0 $(FitRes.t1); book.active$=test; sheet.active$=test; wcol(1)[1]=$(FitRes.t1);

and I can extract t1 to see it in script console.
But I have a big problems on how to insert this value in test sheet in other book. Then, probably, I should go back to original book and sheet to perform another fitting procedure in for().

Can you help me?


marasneo Posted - 05/11/2015 : 08:02:59 AM
Ok,
I am trying with this:
getnlr iw:=__REPORT$ tr:=FitRes pn:=1; type y0 $(FitRes.t1); book.active$=test; sheet.active$=test; wcol(1)[1]=$(FitRes.t1);

and I can extract t1 to see it in script console.
But I have a big problems on how to insert this value in test sheet in other book. Then, probably, I should go back to original book and sheet to perform another fitting procedure in for().

Can you help me?
marasneo Posted - 05/08/2015 : 11:41:05 AM
Thank you Sean,
I will try later and then report about the effects.
SeanMao Posted - 05/08/2015 : 05:23:12 AM
Hi,

You can use following command to output all fitted parameters to a tree:


getnlr tt;
tt.=; // To check the details of all the treenodes


However, you need to assign the value to desired cell manually.

For LabTalk, the following syntax is used to refer to column and cells:

int colnumber = 1;
wcol(colnumber)[i*2]; // i is built-in variable for row index


Regards!

Sean


quote:
Originally posted by marasneo

Thank you Sean!
In that case it is working, but in the result I am getting fitting data as output.
The important thing are summary data or parameters data.
Do you know how to replace 'Data' in 'gg.Output.Data.Book$'?
I've tried with 'Statistics' and nothing - no any output.

Additionally, maybe you know how to go to another row after another for() iteration to build summary of whole plots? - can I use Col(variable)[ii++]; ?

marasneo Posted - 05/08/2015 : 04:08:40 AM
Thank you Sean!
In that case it is working, but in the result I am getting fitting data as output.
The important thing are summary data or parameters data.
Do you know how to replace 'Data' in 'gg.Output.Data.Book$'?
I've tried with 'Statistics' and nothing - no any output.

Additionally, maybe you know how to go to another row after another for() iteration to build summary of whole plots? - can I use Col(variable)[ii++]; ?
SeanMao Posted - 05/08/2015 : 03:02:55 AM
Hi,

For your case, you just need to remove the quotation marks instead:


string labtalk_wstawka_2;
labtalk_wstawka_2.Format("nlbegin iy:=(1,2) func:=expdec1 nltree:=ParamTree; ParamTree.f_y0 = 1; nlfit; nlgui gg 1; gg.quantities.ANOVAtable=0; gg.Output.Data.Book$ = <existing> BookName; gg.Output.Data.Sheet$ = <existing> SheetName; gg.graph1.doplot=0; gg.residuals.graph2=0; nlgui gg 0; gg.=; nlend 1;");
wksb.LT_execute(labtalk_wstawka_2);



where BookName and SheetName are the names of destination book and sheet respectively.

Regards!

Sean
marasneo Posted - 05/07/2015 : 04:08:41 AM
Ok, you are right.
So, I want to execute labtalk code inside C code - everything here is ok:

string labtalk_wstawka_2;
labtalk_wstawka_2.Format("nlbegin iy:=($(xcol2),$(bbc)) func:=expdec1 nltree:=ParamTree; ParamTree.f_y0 = 1; nlfit; nlgui gg 1; gg.quantities.ANOVAtable=0; gg.graph1.doplot=0; gg.residuals.graph2=0; nlgui gg 0; gg.=; nlend 1;");
wksb.LT_execute(labtalk_wstawka_2);

Now, if I would execute this:

gg.Output.Data.Book$ = "<existing> Gaussian" ;

I probably should use something like that (inside the LT_execute):

"gg.Output.Data.Book$ = \"<existing> Gaussian\" ;"

This one is not working.
Off course, I need to create new workbook and worksheet before this code (name Gaussian for both) - it won't work.

Actually... what will be the output of this part?:
gg.Output.Data.Book$ - just a summary (values and errors)?
How to modify my LT code inside c code? Is it possible?

I have whole working script in C, fittings are ok, everything - but how to output the summary of each fitting to another worksheet?
This part of script is working in for(), so each set of the fitting results should be placed in next row of worksheet Gaussian - this is the goal.
SeanMao Posted - 05/06/2015 : 11:26:53 PM
Hi,

I did run the same code in Origin 8.6 SR3 for both 64 bit and 32 bit and it worked as expected.

Can you be more specific about the problem you encountered?

Regards!

Sean

quote:
Originally posted by marasneo

How can you do it:
gg.Output.Data.Book$ = "<existing> Gaussian" ;
in v.86? This one is not working. Also, there is no any advice how to solve such problem :(.
Thanks.

marasneo Posted - 05/05/2015 : 08:46:06 AM
How can you do it:
gg.Output.Data.Book$ = "<existing> Gaussian" ;
in v.86? This one is not working. Also, there is no any advice how to solve such problem :(.
Thanks.
SeanMao Posted - 10/16/2014 : 9:50:19 PM
Hi,
Currently this part of nlgui tree is broken in 9.1 and it will be fixed in our next release. However there is still a workaround to do the job in 9.1:

nlbegin iy:=(col(a),col(b)) func:=gaussian;
nlfit;
nlgui gg 1;
gg.Output.Data.Book$ = "<existing> Gaussian" ; //Suppose source workbook name is Gaussian
gg.Output.Data.Sheet$ = "<existing> Gaussian"; //Suppose source worksheet name is Gaussian
nlgui gg 0;
gg.output.data.=; //Check output information, comment this line if not needed
nlend 1


Have a try and see whether it works.

Regards!

Sean

OriginLab Tech. Service
Chinahgp Posted - 10/16/2014 : 2:25:51 PM
Hi SeanMao
I have same question. but I enter your code into my program. it didn't work the results was outputed to a new workbook as usually.
When I use nolinear fitting dialogue to set output selectionCit is OK.
Could you give me an adviceH
Thank you
yyyhhh Posted - 09/18/2014 : 12:14:40 AM
Thank you for your information.

Now I understand to set the destination in nlgui's tree.
Anyway, in this time, I made a code that the data is outputted into new sheet temporary, then moved into source sheet.

Best,
SeanMao Posted - 09/16/2014 : 06:50:38 AM
Hi,

What you have reported is a bug existed in Origin, I will report this issue to our problem tracking base. I am sorry for the inconvenience.

PS: to set the destination worksheet, you have to specify the workbook first, therefore even if the bug is fixed you should use the following code instead:


nlbegin iy:=(col(a),col(c)) func:=gaussian;
nlfit;
nlgui gg 1;
gg.Output.Data.Book = 1; // int variable, corresponds to <source>
nlgui gg command:=set; // apply the command
gg.Output.Data.Sheet = 0; // int variable, corresponds to <source>
nlgui gg command:=set;
nlgui gg 0;
gg.output.data.=;
nlend 1


Regards!

Sean

OriginLab Tech. Service

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