Matrix from 1D waves
Jonpope
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
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
See http://www.igorexchange.com/node/25
November 1, 2012 at 12:31 pm - Permalink
Jon
November 2, 2012 at 04:57 am - Permalink
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
November 2, 2012 at 08:55 am - Permalink