Converting matrix wave to a triplet wave

Is there a simple way to convert a matrix wave to a triplet wave?

I'm pretty sure I could write out a way to do it, but just wanted to ask if there was a simple conversion.
Maybe not so simple but here is a function that might work for you:

Function matrixToTriplet(inWave)
    Wave inWave
   
    Variable rows=DimSize(inWave,0)
    Variable cols=DimSize(inWave,1)
    Variable points=rows*cols
   
    Make/O/N=(points,3) tripletWave
    Variable x0=DimOffset(inWave,0)
    Variable y0=DimOffset(inWave,1)
    Variable dx=DimDelta(inWave,0)
    Variable dy=DimDelta(inWave,1)
    tripletWave[][0]=x0+dx*mod(p,rows)
    tripletWave[][1]=y0+dy*trunc(p/rows)   
    tripletWave[][2]=inWave[mod(p,rows)][trunc(p/rows)]
End




A.G.
WaveMetrics, Inc.
From the "WM Procedures Index" help file:
Quote:
#include <MatrixToXYZ>

Contains two procedures to convert a two-dimensional matrix of Z values into three separate X, Y, and Z waves. MatrixToXYZ converts the entire matrix into X, Y, and Z waves and MatrixToXYZRange converts a given XY domain into X, Y, and Z waves. The results may be viewed in a graph (as three traces) or in a table (in three columns).

Also contains MatrixToXYZTriplet which converts a two-dimensional matrix of Z values into a XYZ triplet wave (a three-column matrix in which columns 0, 1, and 2 contain the X, Y, and Z data, respectively) such as is used by the 3D plotter Gizmo (see Visualization) and AppendXYZContour.

These routines work on waves in the current data folder only.
--Jim Prouty
Software Engineer, WaveMetrics, Inc.