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
 Modifying WKSANALY.OGS
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

jonni

United Kingdom
58 Posts

Posted - 10/22/2003 :  09:34:33 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi,

Using the correlate function in Origin appends two columns to the worksheet (Lag and Corr). I usually run this from the script window using run.section(WKSANALY,Correlate). The section is included at the end of this mail.

I have a worksheet of type XYYYY... and for many columns the correlation process adds many more, if I wish to (auto)correlate all of them. What I want to do is modify the Correlate section of WKSANALY.OGS to create a new worksheet (with some defining title) with the Lag and Corr columns rather than appending them to the original. The way the section is written it looks as though I need to be careful in the additions/removals I make.

Has anyone done something similar that I can follow as an example?

Many thanks.

jonni


[Correlate]
if (run.section(,CorrSelectionCK)!=0)
return 1;
wks.multiX=1; //Enable Multiple X columns
wks.AddCol(Lag);
wks.col$(wks.ncols).type=4; //Set as X
fft.corr.lagdata$=%(%H,wks.ncols);
wks.AddCol(Corr);
wks.col$(wks.ncols).type=1; //Set as Y
fft.corr.corrdata$=%(%H,wks.ncols);
switch(wks.iscolsel())
{
case 1:
fft.corr.poslag=1;
if (fft.corr(%(%H,wks.c1),%(%H,wks.c1))!=0)
{
doc -uw; //Refresh Worksheet
type -b;
type -b $General.BadCalculation;
}
break;
case 2:
fft.corr.poslag=0;
if (fft.corr(%(%H,wks.c1),%(%H,wks.c1+%(%H,@O,1)))!=0)
{
doc -uw; //Refresh Worksheet
type -b;
type -b $General.BadCalculation;
}
break;
}
set %H -ue;
doc -uw;
return 0;

greg

USA
1380 Posts

Posted - 10/22/2003 :  10:26:54 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
A slight modification to the code sends the results to a new window:

if (run.section(wksanaly,CorrSelectionCK)!=0) return 1;

%M=%H; // Remember the source worksheet
win -t data origin; // Create a target worksheet

wks.multiX=1; //Enable Multiple X columns
wks.AddCol(Lag);
wks.col$(wks.ncols).type=4; //Set as X
fft.corr.lagdata$=%(%H,wks.ncols);
wks.AddCol(Corr);
wks.col$(wks.ncols).type=1; //Set as Y
fft.corr.corrdata$=%(%H,wks.ncols);

win -a %M; // Activate the source worksheet

switch(wks.iscolsel())
{
case 1:
fft.corr.poslag=1;
if (fft.corr(%(%H,wks.c1),%(%H,wks.c1))!=0)
{
doc -uw; //Refresh Worksheet
type -b;
type -b $General.BadCalculation;
}
break;
case 2:
fft.corr.poslag=0;
if (fft.corr(%(%H,wks.c1),%(%H,wks.c1+%(%H,@O,1)))!=0)
{
doc -uw; //Refresh Worksheet
type -b;
type -b $General.BadCalculation;
}
break;
}
set %H -ue;
doc -uw;


Go to Top of Page

jonni

United Kingdom
58 Posts

Posted - 10/22/2003 :  1:21:56 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi greg,

Thanks for your reply. Your suggestion works perfectly!

Best regards,

jonni
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