Hi Dancer,
you can use the following VBS code if you want to calculate the correlation coefficient (-1..1) of two channels.
The channels are expceted to have the same length.
I hope this helps,
Christian
Function Covariance(sgChnX, sgChnY) ' Calculates covariance
' Calculates mean values
Dim dMeanX : dMeanX = CCh(sgChnX, 0)
Dim dMeanY : dMeanY = CCh(sgChnY, 0)
Call ChnCalculate("Ch(""Temp"") = (Ch(""" & sgChnX & """) - " & Str(dMeanX) & ") * (Ch(""" & sgChnY & """) - " & Str(dMeanY) & ")")
Call ChnSum("Temp", "Temp")
Covariance = ChD(CL("Temp"), "Temp") / CL("Temp")
Call ChnDel("Temp")
End Function
Function StdDev(sgChn)
Dim i
For i = 1 To 23
StatSel(1) = "No"
Next
StatSel(14) ="Yes"
StatClipCopy =0
StatClipValue =0
StatFormat =""
StatResChn =0
Call StatBlockCalc("Channel","1-",sgChn) '... StatDirec,RowNoStr,ChnNoStr
StdDev = StatDeviation ' or ChnPropValGet(sgChn, "ResultStatDeviation")
End Function
Function Correlation(sgChnX, sgChnY)
Correlation = Covariance(sgChnX, sgChnY) / (StdDev(sgChnX) * StdDev(sgChnY))
End Function
'Call MsgBox(Correlation("Channel1", "Channel2"))