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
 problems addressing the right columns
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

spulwurm

Germany
Posts

Posted - 02/02/2004 :  2:00:31 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

Mike Buess

USA
3037 Posts

Posted - 02/02/2004 :  3:00:52 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
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