delete points

Hello,
I wondering if somebody could help me,
I need to remove three lines for interval, example: for 4 lines i need to remove 3 leaving 1 intact
thanks so much
I hope I understand you right: You would like to delete every 3 rows/lines out of 4, right? Here is code which deletes all rows besides every nth row:

Function Deleterows(data, every)
	Wave data		//input data
	Variable every		// which nth line to leave
	
	Variable i
	Variable iteration = floor(Dimsize(data,0)/every)
	Variable overhead = Dimsize(data,0) - iteration*every
	for (i=0; i< iteration; i+=1)
		DeletePoints i,every-1, data
	endfor
	if (overhead)
		DeletePoints i,overhead, data
	endif
End


Now you just need to input into the command line:
Deleterows(yourdataname, 4)
Hope that helps. If you would like to know more about the used commands, just take a look into the help browser.
chozo wrote: I hope I understand you right: You would like to delete every 3 rows/lines out of 4, right? Here is code which deletes all rows besides every nth row:

Function Deleterows(data, every)
	Wave data		//input data
	Variable every		// which nth line to leave
	
	Variable i
	Variable iteration = floor(Dimsize(data,0)/every)
	Variable overhead = Dimsize(data,0) - iteration*every
	for (i=0; i< iteration; i+=1)
		DeletePoints i,every-1, data
	endfor
	if (overhead)
		DeletePoints i,overhead, data
	endif
End


Now you just need to input into the command line:
Deleterows(yourdataname, 4)
Hope that helps. If you would like to know more about the used commands, just take a look into the help browser.



Thanks so much it works very well!!


Another way to accomplish this is illustrated here:

•make junk=p		// make a fake data wave
•Make/D/n=(numpnts(junk)/4) reduced_junk
•reduced_junk = junk[4*p]

This has the potential advantage of preserving the original data. It also may be faster because it avoids using an explicit loop. I have not tried comparing timings.

I bet AG comes through with a clever way to use MatrixOP...

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
How about this for extracting a reduced set of the wave into a sparser wave, rather than deleting points:

function sparse(data, every)
	wave data
	variable every
	
	extract data, wsparse, mod(p,every)==0
end

The new destination wave 'wsparse' is specified and created in the 'extract' command, but could easily be converted to an input specification.
Just a small comment on deleting points in a wave or characters from a string:
Work through the data backwards ! It avoids to move points-about-to-be-deleted several times and can be MUCH faster (from waiting 10s to "instant")


for (i=iteration; i>=0; i-=1)

(adjust the limits)

HJ