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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Divide all collums by a constant

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Batou Posted - 10/29/2015 : 06:45:42 AM
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!
2   L A T E S T    R E P L I E S    (Newest First)
cpyang Posted - 10/30/2015 : 10:39:49 PM
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
jasonzhao Posted - 10/29/2015 : 9:23:03 PM
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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000