Delete all NaN (empty points) from a text wave, trailing or scattered

Average rating
(1 vote)

// Handy Function to delete NaNs from TextWaves:
Function DeleteNaNTextwave(W)
Wave /T W
Duplicate /T /O W WwoNaNs
Variable Points = numpnts(WwoNaNs)
InsertPoints Points,1, WwoNaNs // Insert trailing NaN to make loop-break-condition work
Variable i=0, NOP
	Do
	NOP = numpnts(WwoNaNs)
	if((strlen(WwoNaNs [i]) == 0)||(cmpstr("",WwoNaNs [i]) == 0))
		DeletePoints i, 1, WwoNaNs
		i = 0 // Start over again
	else
	i = i+1
	endif	
	while(strlen(WwoNaNs[NOP])==0) // see above
End

Back to top