I have three arrays of the same length in Matlab, X
, Y
and Z
. X(i)
, Y(i)
and Z(i)
forms a pair of 3D coordinates.
The issue now is, how to use these three arrays to generate square meshes, as shown below:
I got the image from mesh plot in Matlab documentation. So obviously mesh
command is not what I want because it plots the meshes itself in the Matlab program, whereas I need the mesh elements ( along with the coordinates) so that I can plot them out myself in other program, such as C#.
In other words, I am looking for the mathematical algorithm to generate the meshes that allows mesh
command to plot the below looking graph.
Edit: I realized that my question wasn't clear after a good night sleep. So here's more detail. I generate x
and y
vector by using this command [x,y]=meshgrid[rangex, rangy]
, and then I define a vector z with the function z(x,y)
. I would have to return a list of square elements ( as shown in the figure below) along with their corresponding x
,y
coordinates. So basically I just want to replot the following graph with those data.
Any ideas?
X,Y,Z
, some sample values of what might be in them, and clarification of what you mean by "element" and "point" (I think by element you are referring to each square in the mesh, and by point you are referring to a set of indices into an array of points which will give you the coordinates of the corners of the square). – gnovice