Display graphed subset of waves in table

Someone asked how to display in a table the graphed subset of waves displayed in graph
using the axis range to determine the subset. This is a quick attempt at a starting point
for that function. It works for waveform data only, not XY data.


Function DisplayGraphDataInTable(graphName)
	String graphName		// "" for top graph
	
	GetAxis /W=$graphName /Q bottom
	Variable axisLeft = V_min, axisRight = V_max
	
	Variable index = 0
	do
		Wave/Z w = WaveRefIndexed(graphName, index, 1)
		if (!WaveExists(w))
			break
		endif
		
		// Just for testing.
		String name = NameOfWave(w)
		Print name
		
		// This assumes that you are displaying waveforms, not XY pairs.
		Variable startPoint = x2pnt(w, axisLeft)
		Variable endPoint = x2pnt(w, axisRight)
		
		String newName = name + "_p"		// _p for "part"
		Duplicate /O /R=[startPoint,endPoint] w, $newName
		
		Wave newWave = $newName
		if (index == 0)
			Edit newWave.id
		else
			AppendToTable newWave.id
		endif
		
		index += 1
	while(1)
End


Forum

Support

Gallery

Igor Pro 10

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More