1 ## Copyright (C) 2007-2012 David Bateman
3 ## This file is part of Octave.
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Function File} {} meshz (@var{x}, @var{y}, @var{z})
21 ## Plot a curtain mesh given matrices @var{x}, and @var{y} from
22 ## @code{meshgrid} and a matrix @var{z} corresponding to the @var{x} and
23 ## @var{y} coordinates of the mesh. If @var{x} and @var{y} are vectors,
24 ## then a typical vertex is (@var{x}(j), @var{y}(i), @var{z}(i,j)). Thus,
25 ## columns of @var{z} correspond to different @var{x} values and rows of
26 ## @var{z} correspond to different @var{y} values.
27 ## @seealso{meshgrid, mesh, contour}
30 function retval = meshz (varargin)
32 [h, varargin, nargin] = __plt_get_axis_arg__ ("meshz", varargin{:});
36 if (ischar (varargin{i}))
42 ## Bundle C matrix back into varargin
43 if (ioff == 3 || ioff == 5)
59 if (isvector (x) && isvector (y))
60 x = [x(1), x(:).', x(end)];
61 y = [y(1); y(:); y(end)];
63 x = [x(1, 1), x(1, :), x(1, end);
64 x(:, 1), x, x(:, end);
65 x(end, 1), x(end, :), x(end, end)];
66 y = [y(1, 1), y(1, :), y(1, end);
67 y(:, 1), y, y(:, end);
68 y(end, 1), y(end, :), y(end, end)];
71 zref = min(z(isfinite(z)));
72 z = [zref .* ones(1, size(z, 2) + 2);
73 zref .* ones(size(z, 1), 1), z, zref .* ones(size(z, 1), 1);
74 zref.* ones(1, size(z, 2) + 2)];
79 tmp = mesh (x, y, z, varargin{ioff:end});
80 unwind_protect_cleanup