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
 Divide all collums by a constant
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Batou

1 Posts

Posted - 10/29/2015 :  06:45:42 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release: Origin Pro 2015G (64bit) Sr1 b9.257
Operating System: Windows 7 ultimate

Hi,
i want to divide all colums of a worksheed exept the first by a constant factor.
This is what i tried:

int ncols = wks.ncols;
for( ii = ncols; ii >= 2; ii--)
{
col(ii)=col(ii)/(250^2/4*pi)
}
But Origin replied that math cannot be used on text colums.
e.g."Mathematik kann nicht auf Textspalten angewendet werden: Book41_ii/(250^2/4*PI)"
Puzzlingly, when i try it without the for loop and with numbers instead aof ii in the console, like:
col(2)=col(2)/(250^2/4*pi)
it works...?
Can you help me? Thanks!

jasonzhao

China
262 Posts

Posted - 10/29/2015 :  9:23:03 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

To run this script, the 'ii' need to be converted to string when used as column index:

for( ii = 6; ii >= 2; ii--)
{
col($(ii))=col($(ii))/(250^2/4*pi);
}

Please see the link below for further example:
http://www.originlab.com/doc/LabTalk/guide/Substitution-Notation#.24.28_.29_Substitution.24.28_.29_Substitution
http://www.originlab.com/doc/LabTalk/guide/Flow-of-Control#For

Best regards!
Jason
OriginLab Technical Service

Edited by - jasonzhao on 10/29/2015 9:23:33 PM
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 10/30/2015 :  10:39:49 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Col(A) needs to be passed in column name, so in order to use index as a variable, you need to use the wcol(ii) function.

for( ii = 6; ii >= 2; ii--)
{
wcol(ii)=wcol(ii)/(250^2/4*pi);
}

See

http://www.originlab.com/doc/LabTalk/ref/Col-func

for explanations.

CP
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