11-02-2017 10:39 AM
Hi,
I am new to DIAdem and it has been a while since I have used VB Script. I have some channels that I want to find the Arithmetic Mean of and am trying to use ChnStatisticsChannelCalc to get the mean of one channel (will be done for many data sets) and then place it into another channel. Currently I have not managed to get any data into the channel. Any ideas where I am going wrong.
Thanks Hannah
Option Explicit 'Forces the explicit declaration of all the variables in a script.
Dim Stat_Result
Call Data.Root.ChannelGroups(1).Channels.Add("Stat_Results",DataTypeChnFloat64)
Set Stat_Result = ChnStatisticsChannelCalc("[1]/TempAmb_Val",32,0,0,0,1,0,"IndexName")
Solved! Go to Solution.
11-06-2017 04:16 AM
Hi Hannah,
The argument description and list of the ChnStatisticsChannelCalc command is here - http://zone.ni.com/reference/en-XX/help/370858N-01/comoff/chnstatisticschannelcalc/ .
The Stats Selection is StatsArithmeticMean which is what you are looking for. However, the start index and the end index are both zero. I think that would from row 0 to row 0 so that would not read all the data.
Does changing this change the result?
Many Thanks,
Riley Ilieva
Applications Engineer
National Instruments
11-07-2017 05:44 AM
Thanks Riley,
Thats has helped, I used recording mode to find ChnStatisticsChannelCalc and it had all of the options set to zero so the help initially confused me.
I managed to achieve want I wanted through this code, as I had not realised that the output is the channel name and not the value.
Thanks Hannah
Option Explicit 'Forces the explicit declaration of all the variables in a script.
Dim Stat_Result
Dim Result
Dim ChLen
Call Data.Root.ChannelGroups(1).Channels.Add("Stat_Result",DataTypeChnFloat64)
Set Stat_Result = Data.Root.ChannelGroups(1).Channels("Stat_Result")
ChLen = Data.GetChannel("[1]/TempAmb_Val").size
Result = ChnStatisticsChannelCalc("[1]/TempAmb_Val",32,1,ChLen,0,1,0,"OnlyName")
Stat_Result(1) = Data.GetChannel("/ArithmeticMean").Maximum