Matrix from 1D waves

Hello All

I'm currently trying to write a small function to convert three vectors, each containing x,y and z values for a microscopy image, into a matrix. Sadly a function is (I think) necessary since I can't use Concatenate due to the x and y values being the matrix coordinates. Here's the sort of conversion I'm after:

1.6 2.3 zvalues
1.7 2.35 zvalues
1.8 2.4 zvalues
1.9 2.45 zvalues

to

....... 1.6 1.7 1.8 1.9
2.3
2.35 ~Zvalues~
2.4
2.45

Unfortunately the setting the x and y coordinate values has thus far proved elusive. I've pasted the procedure I've been able to get so far below, 'Hello' is just a counter: (Apologies I've don't know how to make text appear as it does in a procedure window)


Function CreateMatrix(xwave,ywave,zwave)
	Wave xwave,ywave,zwave
	Variable xx,yy,zz, PntNo, NumOfPnts, Xmax, Ymax, Xmin, Ymin, Width
	Variable Hello

	Wavestats xwave
	NumOfPnts=V_endrow
	NumOfPnts=NumOfPnts+1
	Width=sqrt(NumOfPnts)
	Xmax=V_max
	Xmin=V_min
	Wavestats ywave
	Ymax=V_max
	Ymin=V_min
	Make/O/N=(Width,Width) Image
	SetScale/I x,Xmin,Xmax, Image
	SetScale/I y,Ymin,Ymax, Image

	Hello=0
	PntNo=0
	Do
		xx=xwave(PntNo)
		yy=ywave(PntNo)
		zz=zwave(PntNo)
		Image[xx][yy]=zz
		PntNo=PntNo+1
		Print hello
		hello=hello+1
	While (PntNo<=NumOfPnts)
End


As always any help is greatly appreciated.

Thanks
Jon
Excellent thanks HrodStein, is there anyway to access the procedure for the XYZtoMatrix macro?

Jon
Once you've found the entry for the XYZtoMatrix procedure file in the WM Procedures Index help window, click the little document button on that line. It will add the appropriate #include line to your main Procedure window, load the procedure file, and display the window with the code in it. Instructions for use of the file are in comments at the top.

An easier way to load the procedure file is to select Data->Packages->XYZ to Matrix. But then to see the code you need to select Windows->Procedure Windows->XYZtoMatrix.ipf

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com