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
 Loop for Averaging Set Number of Columns

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
willsand Posted - 10/30/2014 : 3:04:44 PM
Origin Ver. 9.1 (64bit) Sr1
Operating System:Windows 7


Hello,

I have a dataset that has ~300 columns of data and would like to average every 3 columns. I know that with brute force I could just do something like

=(Col(A2)+Col(A3)+Col(A4))/3
rinse and repeat

Given the vast amount of time it would take to input all of the different column assignments, I imagine it would be easier to write a script that averages the first three Y Column values and then have this process loop to the next three column values and so on. It would be great if origin has the ability to create a new workbook that contains only the averaged column values as well.
I have looked through the LabTalk manual on averaging multiple curves but cannot seem to grasp how to write the script I need. Thank you to anyone that can help me with this!
1   L A T E S T    R E P L I E S    (Newest First)
greg Posted - 10/31/2014 : 12:32:00 PM
Something like this:

range raSh = !;
newbook name:=Results;
range raCols = 1, raMeans = 2;
for(ii = 2, row = 1 ; ii <= raSh.ncols ; ii += 3, row++)
{
first = ii;
last = ii + 2;
if(last > raSh.ncols) last = raSh.ncols;
range raC = %(raSh)($(first):$(last));
stats ix:=raC mean:=vMean;
raCols[row]$ = $(first) to $(last);
raMeans[row] = vMean;
}

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