cycling through different waves in a loop
jschroed
I'm trying to write a do-while loop that will do this, but I'm not sure how to write a loop where it will cycle through different waves. Any help would be appreciated!
function test(lim, a1,a2,a3, a4, a5, a6, a7, a8, a9, a10, wavemeans)
wave a1, a2, a3, a4, a5, a6, a7, a8, a9, wavemeans
variable lim
i = 0
do
wavemeans[i]=mean( //this is where I don't know how to call my different a# waves )
i += 1
while(i < lim) //lim is used in case I only want to find the means of a subset of my waves
end
wave a1, a2, a3, a4, a5, a6, a7, a8, a9, wavemeans
variable lim
i = 0
do
wavemeans[i]=mean( //this is where I don't know how to call my different a# waves )
i += 1
while(i < lim) //lim is used in case I only want to find the means of a subset of my waves
end
Wave/WAVE waves // Wave containing an array of wave references
String outputWaveName
Variable numWaves = numpnts(waves)
Make/O/D/N=(numWaves) $outputWaveName
Wave wOut = $outputWaveName
Variable i
for(i=0; i<numWaves; i+=1)
Wave wIn = waves[i]
wOut[i] = mean(wIn)
endfor
return wOut
End
Function Demo()
Make/O/N=100 wave0=gnoise(1), wave1=1+gnoise(1), wave2=2+gnoise(1)
Make/FREE/WAVE theWaves = {wave0, wave1, wave2}
Wave means = FindWaveMeans(theWaves, "MeansWave")
Print means
End
October 19, 2014 at 06:19 pm - Permalink
Out of pure curiosity, how would the trickery solution look like?
Maybe there is some undocumented support for va_arg-style functions :)
October 20, 2014 at 04:02 am - Permalink
Last night I thought there was a way to do it but this morning I don't think so.
October 20, 2014 at 06:44 am - Permalink
October 20, 2014 at 10:41 am - Permalink