How to delete points in a large one-dimensional wave efficiently?
alpha
I want to delete zero points in a large one-dimensional wave(almost 1e7 points). I run the program about 20min but it still not come to end. Is there any efficient way to do this?
Here is my code:
function del()
wave test
variable i
do
if( test[i]==0)
deletepoints i, 1, test
else
i+=1
endif
while(i<numpnts(test))
end
wave test
variable i
do
if( test[i]==0)
deletepoints i, 1, test
else
i+=1
endif
while(i<numpnts(test))
end
WaveTransform zapNaNs test
In the first line each "0" of the wave test is set to not-a-number (NaN). The second line erases all NaN's from a wave.
If you wrap this in a function you might want to use
to speed up things (w would be the wave reference to your wave of interest).
April 28, 2015 at 08:42 am - Permalink
Thanks a lot! Now the pro will be end within one second! It is very useful to operate the whole wave.
Sorry about the Pro, it seems that part of it are not shown on the Website, I do not know why
April 28, 2015 at 09:16 am - Permalink
I have edited your original post to add the tags that mark your procedure as Igor code. See this link for details: http://www.igorexchange.com/node/25
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
April 28, 2015 at 09:28 am - Permalink
You need to use <igor> and </igor> tags when posting code. See http://www.igorexchange.com/node/3221
April 28, 2015 at 09:31 am - Permalink
Thanks for your help.
April 28, 2015 at 05:55 pm - Permalink