can't get correct mean values of list of traces

Hi,

I have loaded 10 waves, each consisting of 70,000 values (electrophysiological recordings, representing Current). I am trying to get one wave with the mean values ,between two points, of all the currently loaded waves starting with "Im_".
The output wave (meanValuesWave) has the right dimensions but does not give the same values as Wave Stats AND every second row is a 0 instead of a mean value. I hope you guys can help me...

Here is the code:

#pragma rtGlobals=3 // Use modern global access method and strict wave access.

Function CreateGraphs()

String x_as = "Time1"
String framelist = WaveList("Im_*",";","")
processWaves(framelist, x_as, 43705, 43715)

end

//##########################################
//##########################################
Function processWaves(list, xaxis, firstPoint, lastPoint)
String list // A semicolon-separated list.
String xaxis
Variable firstPoint, lastPoint


String theWaveName
String newWaveName = "MeansBetweenCursors"
Variable meanBC
Variable index=0

Variable numWaves = ItemsInList(list, ";")
Make/N=(numWaves) $(newWaveName)
WAVE meanValuesWave = $(newWaveName)

For (index = 0; index theWaveName = StringFromList(index, list)
WAVE thisWave = $(theWaveName)


meanValuesWave[index] = mean(thisWave,firstPoint, lastPoint)
index += 1
endFor
End
(You need to use tags to delimit code in forum posts - see http://www.igorexchange.com/node/3221. I have fixed this post for you.)

The complete code did not get posted:

#pragma rtGlobals=3     // Use modern global access method and strict wave access.

Function CreateGraphs()

String x_as = "Time1"
String framelist = WaveList("Im_*",";","")
processWaves(framelist, x_as, 43705, 43715)

end

//##########################################
//##########################################
Function processWaves(list, xaxis, firstPoint, lastPoint)
    String list // A semicolon-separated list.
    String xaxis
    Variable firstPoint, lastPoint

 
    String theWaveName
    String newWaveName = "MeansBetweenCursors"
    Variable meanBC
    Variable index=0
 
    Variable numWaves = ItemsInList(list, ";")
    Make/N=(numWaves) $(newWaveName)
    WAVE/Z meanValuesWave = $(newWaveName)
 
    For (index = 0; index<numWaves; index += 1)
        theWaveName = StringFromList(index, list)
        WAVE thisWave = $(theWaveName)
 
       
        meanValuesWave[index] = mean(thisWave,firstPoint, lastPoint)
        index += 1
    endFor
End
Maybe you could use the "< igor >" ... "< /igor >" environment to post your code (without blanks - see below). This prevents unexpected escape sequences.

Maybe this snippet is what you want:
make /n=1000 test
test=sin(x/100)+gnoise(1)
Duplicate/O test,test_samp
Resample/DOWN=2 test_samp


For details please have a look at
displayhelptopic "resample"

HJ
You are incrementing index twice each time through the loop. Remove the last statement before "endfor".

Note that the mean function takes X values, not point numbers, as parameters. If you are not sure about the difference between X values and point numbers, execute this:
DisplayHelpTopic "The Waveform Model of Data"