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
 Origin Forum
 Script Help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

binowizu

13 Posts

Posted - 12/21/2018 :  05:15:18 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

YimingChen

1609 Posts

Posted - 12/21/2018 :  10:23:42 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

binowizu

13 Posts

Posted - 12/21/2018 :  12:02:24 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you! it works perfectly
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