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
 Average of filtered 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

achu6393

India
38 Posts

Posted - 03/14/2017 :  12:02:54 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I am trying to get average of a column which is already filtered by particular ranges. I can achieve this through options. For example, apply a filter range for col(A) between 0-15 and then if I select the col(b) I can view the average of the filtered average in the status bar. But can I write a Labtalk script to get these averages an store in a separate worksheet?

Origin Ver. and Service Release: 9.3
Operating System: Win7

such coding! much wow!

yuki_wu

896 Posts

Posted - 03/15/2017 :  02:59:18 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Labtalk can certainly do this, for example:

string strCond$ = "col(A) > 0 && col(A) < 15";
ave = averageif(col(B),strCond$);
[book1]sheet2!Cell(1,1)=ave;

Know more about averageif:
http://www.originlab.com/doc/LabTalk/ref/Averageif-func

Regards,
Yuki
OriginLab
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 03/15/2017 :  04:51:17 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It seems that 2016 did not handled filtered value in LabTalk functions but 2017 works fine.

Assuming you have col(A) with a filter enabled, then

mean(col(A))=;

will dump the correct result consistent with status bar in 2017 but not in 2016 (9.3)

CP
Go to Top of Page

snowli

USA
1384 Posts

Posted - 03/15/2017 :  10:05:38 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

there is a system variable @GHM that controls ignore hidden rows or not.
In 2016, it's 0, which will not ignore hidden rows. But in Origin 2017, we changed default to -1 which is follow worksheet settings (which is ignore by default).

So in Origin 2016, if you set it to 1, it will ignore hidden rows.
You can change the default value of system variables in Tools: System Variables dialog.

http://www.originlab.com/doc/Origin-Help/System-Variable-Dialog


Origin 2017 also improved this so more analysis tools will handle hidden rows.

Thanks, Snow
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