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
 Average of a part of a column
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

bvg15

6 Posts

Posted - 10/21/2015 :  9:55:35 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 8
Operating System: Win 7

Hello,

I want to get an average of a set of values in a column and save the average value in a cell within the same data sheet. I tried the syntax suggested in the link below.

http://www.originlab.com/forum/topic.asp?TOPIC_ID=18781

I tried using the same values to test whether the script works but the average value displayed is 0 instead of the expected average value. What could be the problem? Also, is it possible do the same but for several sets of values in the same column using the same syntax? Finally, is it possible to run the same syntax on several data sheets simultaneously?

Thanks for your help.

Shirley_GZ

China
Posts

Posted - 10/22/2015 :  02:37:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,
Please run the script lines below to calculate the average values for every 5 rows of col(A) in current worksheet:
loop(ii,1,4)
{
jj=ii*5-4;
range rr=col(A)[jj:jj+4];
sum(rr);
mymean=sum.mean;
col(B)[ii]=mymean;
}

To run the same syntax on all worksheets in current project simultaneously, you can use doc –e command. See the example below:
Doc –e LB
{
range rr=col(A)[1:5];
sum(rr);
mymean=sum.mean;
col(B)[1]=mymean;
}


http://www.originlab.com/doc/LabTalk/ref/Document-cmd#-e_object_.7Bscript.7D.3B_Execute_the_given_script_for_all_objects

Originlab Technical Service Team

Edited by - Shirley_GZ on 10/22/2015 02:40:01 AM
Go to Top of Page

bvg15

6 Posts

Posted - 10/26/2015 :  11:03:42 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you.
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