mesh() and surf() errors & sorting [x, y, z] matrix into meshgrid matrix.

Ben Abbott bpabbott at mac.com
Mon Jul 7 14:02:17 CDT 2008


On Monday, July 07, 2008, at 02:51PM, "Michael Barton" <bartonm09 at gmail.com> wrote:
>I have a large collection of data points in the form of (x,y,z) coordinates
>stored in an [N,3] matrix.  Octave can successfully run: plot3() with any
>warnings or errors.  However, I need to use contour() and surface plots like
>surf() and mesh().  Unfortunately, Octave crashes with a memory error with
>the command: contour().
>
>As for surf() and mesh(), the following error messages are returned:
>surf(DataSet(:,1),DataSet(:,2),DataSet(:,3)):
>error: rows(z) must be the same as length(y) and columns (z) must be the
>same as length(x)
>...
>
>mesh(DataSet(:,1),DataSet(:,2),DataSet(:,3)):
>error: rows(z) must be the same as length(y) and columns (z) must be the
>same as length(x)
>...
>
>>From the documentation, surf() and mesh() require the a grid of x and y data
>to be established.  Is there anyway to sort the DataSet matrix in such a way
>that surf() and mesh() plot successfully?
>

Can you give more information regarding the data?

(1) Is the x-data and y-data on a 2D grid?

(2) Is the data ordered?

If the answers to both (1) and (2) are "yes" then using "reshape" should be able to produce the 2D vectors for x, y, and z that are compatible with mesh and surf.

Ben


More information about the Help-octave mailing list