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
 How to output nlfit results into source sheet?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

yyyhhh

Japan
2 Posts

Posted - 09/16/2014 :  02:34:36 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

SeanMao

China
288 Posts

Posted - 09/16/2014 :  06:50:38 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

yyyhhh

Japan
2 Posts

Posted - 09/18/2014 :  12:14:40 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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,
Go to Top of Page

Chinahgp

1 Posts

Posted - 10/16/2014 :  2:25:51 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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 selectionCit is OK.
Could you give me an adviceH
Thank you

Edited by - Chinahgp on 10/16/2014 2:26:45 PM
Go to Top of Page

SeanMao

China
288 Posts

Posted - 10/16/2014 :  9:50:19 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

marasneo

Poland
9 Posts

Posted - 05/05/2015 :  08:46:06 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.
Go to Top of Page

SeanMao

China
288 Posts

Posted - 05/06/2015 :  11:26:53 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.

Go to Top of Page

marasneo

Poland
9 Posts

Posted - 05/07/2015 :  04:08:41 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.
Go to Top of Page

SeanMao

China
288 Posts

Posted - 05/08/2015 :  03:02:55 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

marasneo

Poland
9 Posts

Posted - 05/08/2015 :  04:08:40 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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++]; ?

Edited by - marasneo on 05/08/2015 04:14:27 AM
Go to Top of Page

SeanMao

China
288 Posts

Posted - 05/08/2015 :  05:23:12 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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++]; ?

Go to Top of Page

marasneo

Poland
9 Posts

Posted - 05/08/2015 :  11:41:05 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you Sean,
I will try later and then report about the effects.
Go to Top of Page

marasneo

Poland
9 Posts

Posted - 05/11/2015 :  08:02:59 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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?
Go to Top of Page

SeanMao

China
288 Posts

Posted - 05/12/2015 :  02:19:33 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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?


Go to Top of Page

marasneo

Poland
9 Posts

Posted - 05/12/2015 :  06:42:19 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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?

Edited by - marasneo on 05/12/2015 10:50:15 AM
Go to Top of Page

SeanMao

China
288 Posts

Posted - 05/12/2015 :  9:45:40 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
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