Mercurial > hg > octave-lyh
comparison scripts/plot/mesh.m @ 7109:5436efbf35e3
[project @ 2007-11-06 22:16:25 by jwe]
author | jwe |
---|---|
date | Tue, 06 Nov 2007 22:16:25 +0000 |
parents | a1dbe9d80eee |
children | 0e63f1126f01 |
comparison
equal
deleted
inserted
replaced
7108:60a1165732f9 | 7109:5436efbf35e3 |
---|---|
28 ## @seealso{meshgrid, contour} | 28 ## @seealso{meshgrid, contour} |
29 ## @end deftypefn | 29 ## @end deftypefn |
30 | 30 |
31 ## Author: jwe | 31 ## Author: jwe |
32 | 32 |
33 function h = mesh (x, y, z) | 33 function h = mesh (varargin) |
34 | 34 |
35 newplot (); | 35 newplot (); |
36 | 36 |
37 if (nargin == 1) | 37 tmp = surface (varargin{:}); |
38 z = x; | 38 ax = get(tmp, "parent"); |
39 if (ismatrix (z)) | 39 set (tmp, "FaceColor", "none"); |
40 [nr, nc] = size (z); | 40 set (tmp, "EdgeColor", "flat"); |
41 x = 1:nc; | 41 set (ax, "view", [-37.5, 30]); |
42 y = (1:nr)'; | |
43 else | |
44 error ("mesh: argument must be a matrix"); | |
45 endif | |
46 elseif (nargin == 3) | |
47 if (isvector (x) && isvector (y) && ismatrix (z)) | |
48 if (rows (z) == length (y) && columns (z) == length (x)) | |
49 x = x(:)'; | |
50 y = y(:); | |
51 else | |
52 msg = "mesh: rows (z) must be the same as length (y) and"; | |
53 msg = sprintf ("%s\ncolumns (z) must be the same as length (x)", msg); | |
54 error (msg); | |
55 endif | |
56 elseif (ismatrix (x) && ismatrix (y) && ismatrix (z)) | |
57 if (! (size_equal (x, y) && size_equal (x, z))) | |
58 error ("mesh: x, y, and z must have same dimensions"); | |
59 endif | |
60 else | |
61 error ("mesh: x and y must be vectors and z must be a matrix"); | |
62 endif | |
63 else | |
64 print_usage (); | |
65 endif | |
66 | |
67 ## make a default line object, and make it the current axes for the | |
68 ## current figure. | |
69 ca = gca (); | |
70 | |
71 tmp = __go_surface__ (ca, "xdata", x, "ydata", y, "zdata", z); | |
72 | |
73 set (ca, "view", [-37.5, 30]); | |
74 | |
75 if (nargout > 0) | 42 if (nargout > 0) |
76 h = tmp; | 43 h = tmp; |
77 endif | 44 endif |
78 | 45 |
79 endfunction | 46 endfunction |