XYZtoMatrix

I am having an issue when using XYZtoMatrix.

I have and X, Y, X data set which is complete (i.e. doesn't require interpolation) and I just want to put it in a grid however when I use the XYZtoMatrix it does not seem to scale correctly.

Not sure what I am doing wrong.

Thanks for any help.

Matthew

Experiment_10.pxp
Your XYZ triplets are in an unusual order- they describe a serpentine pattern rather than a raster scan. That is, the X values start low and go up, then from there start high and go down, etc. The usual way to make gridded XYZ triplets into a matrix is simply to redimension the Z values into the appropriately dimensioned matrix. For your data (a 25x25 matrix):
Duplicate/O zwave, matrix2
redimension/N=(25,25) matrix2

Now every other column is in the reverse order. So I wrote this little function to reverse the order of every other column:
Function ReverseOddColumns(Wave w)
    Variable nrows = DimSize(w, 0)
    Variable ncols = DimSize(w, 1)
    Make/N=(nrows)/FREE temp
    Variable i
    for (i = 1; i < ncols; i+=2)
        temp = w[p][i]
        w[][i] = temp[nrows-p-1]
    endfor
end

Invoke the function on our matrix:
•ReverseOddColumns(matrix2)

To reflect the increment in X and Y values, set the scaling of the matrix:
SetScale/I y 1.25, -1.25, matrix2
SetScale/I x -1.25, 1.25, matrix2

Note that the Y scaling is reversed, to reflect another oddity of your data set: the Y values start high and go down. We could reverse the order of the columns instead, if that were advantageous.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Thanks. I thought the odd data collection order might have been the issue. Matthew