02-17-2011 08:05 AM
Hi everybody
I have got 40 channels. Names look like "A1 B1", "A1 B2", ... "A1 B8", "A2 B1", ... "A2 B8", ... "A5 B8"
"Dimension" is 5x8 (AxB).
I would like to run script witch will calculate 'mean' for channels "Ax B1" to "Ax B8" and save result to new channel "mean Ax".
AND
Script witch will calculate mean with channels "A1 Bx" to "A5 Bx" and save result to new channel "mean Bx".
Complication: Same channels could be missing for example there will be 38 channels without "A2 B5" and "A5 B2"
02-18-2011 10:13 AM
Hi JCC,
I think it would be best to either post or email (brad.turpin@ni.com) an example data set. I'm willing to create a quick VBScript to do these calculations, but it would be hugely helpful to be able to test that VBScript on the right data set during development. Do you want the Ax and Bx channels to have one value each which is the matrix average or 8 values for each Ax channel and 5 values for each Bx channel? Asked a different way, should the average calculation always be just over 1 channel?
Brad Turpin
DIAdem Product Support Engineer
National Instruments
02-22-2011 10:47 AM
Hi Brad
Thank you for your replay.
I am attaching example data set.
Channel names are combination of A and B when A = 1 to 5 and B = 1 to 8.
I want generate channels list Ax which will include this channels: (AxB1, AxB2, AxB3, AxB4, AxB5, AxB6, AxB7, AxB8). Later I will use this channels list to calc 'mean' or 'standard deviation'.
For this I could use VBScript command:
And I want generate channels list Bx which will include this channels: (A1Bx, A2Bx, A3Bx, A4Bx, A5Bx)
For this I could use VBScript command:
Script must check if channel name is valid. If Channel name is invalid then must be removed from channels list because calc function will return Error. (Same channels could be missing)
02-23-2011 03:52 PM
Hi JCC,
This is what I think you're asking for:
OPTION EXPLICIT Dim ChStems, ChStem, ChnStr Call GroupCreate("Averages") Call GroupDefaultSet(GroupCount) ChStems = Array("A1 Bx", "A2 Bx", "A3 Bx", "A4 Bx", "A5 Bx", "Ax B1", "Ax B2", "Ax B3", "Ax B4", "Ax B5", "Ax B6", "Ax B7", "Ax B8") FOR Each ChStem In ChStems ChnStr = GetChnStr(ChStem) Call ChnAverage(ChnStr, ChStem) NEXT ' ChStem Function GetChnStr(ChStem) Dim i, ChName, ChNum, ChnStr ChnStr = "" ChStem = UCase(Trim(ChStem)) FOR i = 1 TO 8 ChName = Replace(ChStem, "X", i) ChNum = CNo(ChName) IF ChNum > 0 THEN ChnStr = ChnStrAdd(ChnStr, ChNum) NEXT ' i GetChnStr = ChnStr End Function ' GetChnStr()
Brad Turpin
DIAdem Product Support Engineer
National Instruments