error in submatrix operation in MatrixOP

The following code, which worked fine in older versions like igor 7, throws an error in igor 9 due to "Bad range specification".

	MatrixOP/O/S wDataMeanZ = mean(wData[][][p])

I basically want to create a 1D array "wDataMeanZ" with the size of the layer by taking the mean of the row-column space of the 3D matrix "wData", but I want to keep the code concise with 1 line as above. Is there any other similar code that replaces this without using a lengthy function like for-loop? 

 

I'm not sure how this could have worked in IP8 because the index 'p' is not something you can use in MatrixOP.

I suggest you use MatrixOP layer() function instead of the bracket notation.

In reply to by Igor

Igor wrote:

 ....but I want to keep the code concise with 1 line as above

then you probably need a wrapper function such as:

Make/D/O/N=(DimSize(wData,2)) wDataMeanZ = wrapper(wData,p)

function wrapper(wave w, variable i)
    MatrixOP/FREE avg = mean(layer(w,i))
    return avg[0]
end

or you could use

ImageStats/BEAM wData