Function Test()
// make some test data
Make/O/N=10 wData={5,3,4,5,6,2,1,7,0,9}
// copy to a 'result' wave
Duplicate/O wData,wFilteredData
// use conditional to set certain values to NaN
wFilteredData[] = wFilteredData[p]>5 ? wFilteredData[p] : NaN
// remove the NaNs
WaveTransform zapNaNs wFilteredData
// display the data in a table
Edit wData,wFilteredData
End
Function Test()
// make some test data
Make/O/N=10 wData={5,3,4,5,6,2,1,7,0,9}
// extract values > 5
Extract wData, wFilteredData, wData > 5
// display the data in a table
Edit wData,wFilteredData
End
Function Test()
// make some test data
Make/O/N=10 wData={5,3,4,5,6,2,1,7,0,9}
// extract values > 5
Extract wData, wFilteredData, wData > 5
// display the data in a table
Edit wData,wFilteredData
End
hm, yes, shorter but not necessarily faster…well, at least not on large data sets ;-)
function speed1(w)
wave w
variable num = StartmsTimer
Duplicate/O w nw
Multithread nw = w > 3 ? w : NaN
Wavetransform zapNaNs nw
print Stopmstimer(num)/1e6
end
function speed2(w)
wave w
variable num = StartmsTimer
Extract/O w, nw, w > 3
print Stopmstimer(num)/1e6
end
•make/N=1e7 test = enoise(5)
•speed1(test)
0.509921
•speed2(test)
1.08944
Hope this helps.
February 19, 2014 at 01:48 am - Permalink
An attempt was made to treat a text wave as if it were a numeric wave.
I didn't think I had a text wave... The example with your wData wave works though.
February 19, 2014 at 02:03 am - Permalink
where tWave is your text wave.
February 19, 2014 at 02:12 am - Permalink
"got 'tWave' instead of a string variable or string function name"
nWave = str2num(tWave[p])
February 19, 2014 at 02:30 am - Permalink
February 19, 2014 at 02:51 am - Permalink
February 19, 2014 at 04:25 am - Permalink
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
February 19, 2014 at 11:24 am - Permalink
February 19, 2014 at 11:11 pm - Permalink
hm, yes, shorter but not necessarily faster…well, at least not on large data sets ;-)
February 19, 2014 at 11:17 pm - Permalink