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
 copy fit result into worksheet
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

RobertWeng

Germany
Posts

Posted - 01/12/2007 :  09:17:27 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 6.0
Operating System: windows xp home edition SP2

I have 25 worksheets.
In each worksheet there are 9 columns with Y plot designation
and 9 columns with corresponding X plot designation


1) I want to plot 25 times 9 graphs (all the corresponding XY columns)

2) I want to fit linear all of them.

3) I want to save automatically the slopes and errors of linear fit
into a worksheet.

4) I want to plot the slopes and errors on a graph.

How can I do that??

plz. help me..

I've never used computer programming... help me~~!!!

Mike Buess

USA
3037 Posts

Posted - 01/12/2007 :  11:58:02 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The following script should work. You can run it from the Custom Routine button as described here.


// loop through all worksheets in project
doc -e W
{
if("%[%H,7]"!="Slopes") // skip if it's a slopes wks
{
%W=%H; // save wks name
GetEnumWks Slopes; // create new slopes wks
%A=%H; // save its name
// prepare columns
wks.col1.name$=Dataset;
wks.col2.name$=Slope;
wks.AddCol(yErr);
wks.col3.type=3;
page.label$=Linear fits of %W; // label the slopes wks
page.title=3;
win -a %W; // restore data wks
wo -s 0 0 0 0; // select all columns
wo -p 201; // create scatter plots
win -i %W; // minimize data wks
page.label$=Data from %W; // label the graph
page.title=3;
ii=1; // perform linear regression on all dataplots, store slopes
doc -e D
{
if("%[%C,>'_']"!="Line")
{
lr %C; // perform linear regression
%A_Dataset[ii]$=%C; // save dataset name to slopes wks
%A_Slope[ii]=lr.b; // save slope
%A_yErr[ii]=lr.sdb; // save std dev of slope
ii++;
};
};
win -a %A; // restore slopes wks
wo -s 0 0 0 0; // select all columns
wo -p 201; // create scatter plots
win -i %A; // minimize slopes wks
page.label$=Data from %A (%W); // label the wks
page.title=3;
};
};


Mike Buess
Origin WebRing Member
Go to Top of Page

RobertWeng

Germany
Posts

Posted - 01/16/2007 :  07:41:30 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you very much Mike!
It works perfect!

What I forgot to mention is that I have some other worksheets open as wel.
This script loops through all of them.
Is there a way that it loops only through the 25 DATA worksheets ?

Thank you very much !!
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 01/16/2007 :  08:27:14 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Replace if("%[%H,7]"!="Slopes") with if("%(%H,5)"=="Data").

Mike Buess
Origin WebRing Member
Go to Top of Page

RobertWeng

Germany
Posts

Posted - 01/16/2007 :  08:47:42 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Now it doesn´t do anything at all...
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 01/16/2007 :  09:18:09 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You must have copied something wrong or else you did not notice the change in my post. if("%(%H,5)"=="Data") means if worksheet name starts with Data as you want.

Mike Buess
Origin WebRing Member
Go to Top of Page

RobertWeng

Germany
Posts

Posted - 01/17/2007 :  05:56:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I found the problem:

It should have been if("%[%H,5]"=="Data")
insteat of if("%(%H,5)"=="Data")

Now it works perfektly !

Thank´s !!!!!
Go to Top of Page

RobertWeng

Germany
Posts

Posted - 01/18/2007 :  09:43:55 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I noticed the names of the slopes worksheet are all randomly.

Is it possible to link the name of the slopes worksheet with the graph the slopes are taken from ?

For example;

save the 9 slopes of graph1 into the worksheet slopes1
save the 9 slopes of graph2 into the worksheet slopes2

and so on ...

Thank you very very much if this works !!!!
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 01/18/2007 :  12:06:28 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
doc -e W
{
if("%[%H,5]"=="Data") // skip if it's a slopes wks
{
%W=%H; // save wks name
wo -s 0 0 0 0; // select all columns
wo -p 201; // create scatter plots
page.label$=Data from %W; // label the graph
page.title=3;
%A=%H; // save graph name
win -i %W; // minimize data wks
win -t D; // create new wks
%B=Slopes%[%A,>5] ;
win -r %H %B;
// prepare columns
wks.col1.name$=Dataset;
wks.col2.name$=Slope;
wks.AddCol(yErr);
wks.col3.type=3;
page.label$=Linear fits of %A; // label the slopes wks
page.title=3;
win -a %A;
ii=1; // perform linear regression on all dataplots, store slopes
doc -e D
{
if("%[%C,>'_']"!="Line")
{
lr %C; // perform linear regression
%B_Dataset[ii]$=%C; // save dataset name to slopes wks
%B_Slope[ii]=lr.b; // save slope
%B_yErr[ii]=lr.sdb; // save std dev of slope
ii++;
};
};
win -a %B; // restore slopes wks
wo -s 0 0 0 0; // select all columns
wo -p 201; // create scatter plots
win -i %B; // minimize slopes wks
page.label$=Data from %B; // label the graph
page.title=3;
};
};


Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 01/18/2007 12:10:01 PM
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