Vous êtes sur la page 1sur 2

[Statistics on rows]

;
#//row stats on all columns to the left
//we will do all the scripting here, column formula can be empty
const nn=_ThisColNum;
range mean=wcol(nn), sd=wcol(nn+1), npts=wcol(nn+2);

RowStats 1:wcol(nn-1) mean:=mean sd:=sd n:=npts;

sd.type = 3;//YErr
mean.type = 1;//Y
npts.type = 2;//disregard, not to plot

ss$=mean.Label$; if(ss.IsEmpty()) mean.Label$="Mean";


ss$=sd.Label$; if(ss.IsEmpty()) sd.Label$="StDev";
ss$=npts.Label$; if(ss.IsEmpty()) npts.Label$="N Size";

[Sample Using Ranges]


A*exp(-rr/w);
#// This sample expects data in columns 1 and 2
// Whatever column this is run in will be replaced
// with result
// declare range for col(1) and col(2)
range x=1,y=2;

// temp dataset as intermediate variable


dataset rr;
rr = x^2+y^2;

// also declare some local constants


const A=12.3, w = 2*pi;

// show these values whenever col is updated


ty -a;list a;

[Relative Column Index]


(a+b)/2;
#//you can update values on the next column as well
const nn=_ThisColNum;
range a=wcol(nn-2),b=wcol(nn-1);
range next=wcol(nn+1);
next=(a-b)/2;

[Relative Column and Row Index]


;// Nothing to do here
#// Copy two columns inverted and shifted down
newbook;
end = 10; // 10 rows
col(1) = data(1,end);
col(2) = uniform(end);
wks.ncols = 4;
// Illustrate relative addressing in column and rows
loop(jj,3,4)
{
for( ii = end ; ii > 0 ; ii-- )
{
wcol(jj)[end - ii + 7] = wcol(jj-2)[ii];
}
}

[Normalize column 0 to 1]
;
#// Get index of current column
const nn = _ThisColNum;
// Get min and max using stats XF
stats wcol(nn);
// Subtract min and scale by (max-min)
wcol(nn) -= stats.min;
wcol(nn) /= (stats.max - stats.min);

[Fill Multiple Columns of data]


;
#// simply fill 100 columns of data
//columns will be automatically added by the wcol function
loop (i,1,100) {
wcol(i)={0:0.01:i+2};
}

[Difference between rows]


diff(col(A));
#// Calculates row by row difference

[Compute cumulative sum]


;
#// Get index of current column
const nColIn = _ThisColNum;
// Add a new column for sum output
wks.addcol();
const nColOut = wks.ncols;
// Compute sum and set long name of output col
wcol(nColOut) = sum(wcol(nColIn));
wcol(nColOut)[L]$ = "Sum of " + wks.col$(nColIn).name$;

[Calculation between columns in another sheet]


a*b;
#//New a workbook within one sheet
%a=%h;
newbook name:=SampleData sheet:=1 option:=1;
//Declare range for columns in the 1st sheet of another book
range a=[SampleData]1!1, b=[SampleData]1!2;
a={1:10};
b={0.1:0.1:1};
win -a %a;

[Adding 1st two columns]


a+b;
#// declare range for col(1) and col(2)
range a =1, b=2;

Vous aimerez peut-être aussi