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
 Origin Forum
 Script Help

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
binowizu Posted - 12/21/2018 : 05:15:18 AM
Origin Ver. and Service Release (Select Help-->About Origin): 8.5.0 SR1
Operating System: Win7 x64



Hello everyone,

I need help if someone can help me.
I want to write a simple script but I am new to Labscript.
So here is my situtation:
-I have a worksheet with n columns and 256 rows
-I want to add new (n-1) columns
-I want to fill these new columns with calculations done on my previous data:
-for example, for the first new column : the calculation I want to do is col(B) divided by the mean of subrange rows in col(B) (ie [1:16] and [241:256] so for the mean I just want the mean of my extrem values 16 first and last rows)
-for the second new colum, the same calculation but with col(C)
-etc

Best regards
2   L A T E S T    R E P L I E S    (Newest First)
binowizu Posted - 12/21/2018 : 12:02:24 PM
Thank you! it works perfectly
YimingChen Posted - 12/21/2018 : 10:23:42 AM
Hi,

Please try the following script:

ncols = wks.nCols;
nsub = 16;
for (int i=1; i <= ncols; i++)
{	
	n = count(wcol(i));
	avgi = (total(wcol(i)[1:nsub])+total(wcol(i)[n-nsub+1:n]))/(2*nsub);
	wks.AddCol();
	wcol(ncols+i) = wcol(i)/avgi;
	wcol(ncols+i)[L]$ = "NewCol$(i)";
}


Thanks,
James

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