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
 Loop for Averaging Set Number of Columns
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

willsand

USA
2 Posts

Posted - 10/30/2014 :  3:04:44 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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!

greg

USA
1378 Posts

Posted - 10/31/2014 :  12:32:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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;
}
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