| Author |
Topic  |
|
|
jonni
United Kingdom
58 Posts |
Posted - 10/22/2003 : 09:34:33 AM
|
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
|
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;
|
 |
|
|
jonni
United Kingdom
58 Posts |
Posted - 10/22/2003 : 1:21:56 PM
|
Hi greg,
Thanks for your reply. Your suggestion works perfectly!
Best regards,
jonni |
 |
|
| |
Topic  |
|
|
|