06-05-2021 09:09 AM
Hi,
I know this is an old thread. But, I have been trying to calculate average of a channel and copy to a variable.
I have tried this statement. Call Calculate("average=CCh(36,0)")
But, I keep getting an error 'Cannot assign the calculation result to the left side of the formula'
Can you please help me with it?
06-07-2021 05:15 PM
Hi Rishi,
Any variables in the formula of the Calculate() command have to be global DIAdem variables. You can use the existing temporary variables such as L1, R1, T1, ... or you can elevate any VBScript variable to global status with the GlobalDim command:
GlobalDim "average"
Call Calculate("average=CCh(36,0)")
MsgBox average
You could alternatively call the statistics command in the ANALYSIS panel (parametrized to calculate the average) and access the global variable it fills for the average calculation
Call ChnStatisticsChannelCalc(36, eStatsArithmeticMean)
MsgBox StatsResult(eStatsArithmeticMean)
Brad Turpin
Principal Technical Support Engineer
NI
06-08-2021 04:34 AM
Hi Brad, Thanks so much. I have used the calc functions.
For future references, please find below code snippet.
Set ChnResult = ChnSavitzkyGolayFilter("Dummy", "Median", 4, 200)
call ChnStatisticsChannelCalc(oMyChn, eStatsArithmeticMean)
X1value=StatsResult(eStatsArithmeticMean)