
Function for appending a new value to an existing wave

PeterR
// Handy Function to append a new value to an existing 1-dimensional wave Function AppendValue(thewave, thevalue) Wave thewave Variable thevalue Redimension /N=(numpnts(thewave)+1) thewave thewave [numpnts(thewave)] = thevalue End

Forum

Support

Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More
Better write it as
Or even as
That also works with multidimensional waves.
Keep in mind that this is might be slow as Redimension might need to allocate memory.
June 11, 2014 at 06:35 am - Permalink
thewave [size] = thevalue
will not do what you expect if you feed it a matrix wave. Might be better to writethewave[size][0][0][0] = thevalue
But trying to come up with a reasonable behavior for waves of any dimensionality is probably futile. What is the correct way to add one value to a matrix? Add a row and fill the first value of the row with the new value, and zeroes in the rest of the row? Fill the entire row with the new value? Add a column and then ask the same questions? And the question expands exponentially with increasing dimensionality...
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
June 11, 2014 at 09:26 am - Permalink