| T O P I C R E V I E W |
| spulwurm |
Posted - 02/02/2004 : 2:00:31 PM Hi. I'm new to Labtalk and have a problem with addressing the right columns for my calculations. What I wanted to do is take every second column from worksheet data1 and write the logarithm of it into a column on worksheet data2. Then do a linear regression on this column and write the slope and the intercept into a worksheet data3. What I came up with so far is this:
data2_a=log(data1_a);\\set first col in data2 to log(data1)(x column) in=0; loop(ii,2,12) { in=in+2; \\choose column 2,4,6,8... data2_wks.cName$(ii)$=log(data1_wks.cName$(in)$) lr data2_wks.cName$(ii)$;\\ linear regression data3_a[ii]=ii-1; \\set first column as an index from 0 to n data3_b[ii]=lr.a; \\write parameters data3_c[ii]=lr.sdA; data3_d[ii]=lr.b; data3_e[ii]=lr.sdB; data3_f[ii]=lr.b/4; \\calc D
};
The problem I have is that data1_wks.cName$(number)$ does not work, or, what is more likely, I'm getting the syntax wrong. I found this use of wksName_wks.cNamen$ in one of the threads in this forum where n$ is supposed to be the column number. If I type in everything by hand like
data2_b=log(data1_b); lr data2_b; ...
everything works fine. I just can't get Origin to run through the columns.
Thanks for your help!
PS: I'm using Origin 5.0
|
| 1 L A T E S T R E P L I E S (Newest First) |
| Mike Buess |
Posted - 02/02/2004 : 3:00:52 PM You only end a variable name with $ when you're referring to a string. Try this in place of lines 2 and 3 of your loop...
%P=data1!wks.cName$(in)$; // col name in data1 %Q=data2!wks.cName$(ii)$; // col name in data2 data2_%Q=log(data1_%P); lr data2_%Q;
Or, even better, don't use the column names at all...
%(data2,ii)=log(%(data1,in)); lr %(data2,ii);
Mike Buess Origin WebRing Member |
|
|