annotate scripts/plot/meshz.m @ 14872:c2dbdeaa25df

maint: use rows() and columns() to clarify m-files. * gradient.m, interp1q.m, rat.m, tsearchn.m, image.m, imwrite.m, area.m, contourc.m, hist.m, isocolors.m, isonormals.m, meshz.m, print.m, __bar__.m, __go_draw_axes__.m, __interp_cube__.m, __marching_cube__.m, __patch__.m, __print_parse_opts__.m, __quiver__.m, rose.m, shrinkfaces.m, stairs.m, surfnorm.m, tetramesh.m, text.m, deconv.m, spline.m, intersect.m, setdiff.m, setxor.m, union.m, periodogram.m, pcg.m, perms.m: Replace size (x,1) with rows (x) and size(x,2) with columns(x).
author Rik <octave@nomad.inbox5.com>
date Tue, 17 Jul 2012 13:34:19 -0700
parents 5d3a684236b0
children c9346014fed2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
1 ## Copyright (C) 2007-2012 David Bateman
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
2 ##
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
4 ##
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
8 ## your option) any later version.
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
9 ##
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
14 ##
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
18
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
20 ## @deftypefn {Function File} {} meshz (@var{x}, @var{y}, @var{z})
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
21 ## Plot a curtain mesh given matrices @var{x}, and @var{y} from
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
22 ## @code{meshgrid} and a matrix @var{z} corresponding to the @var{x} and
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
23 ## @var{y} coordinates of the mesh. If @var{x} and @var{y} are vectors,
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
24 ## then a typical vertex is (@var{x}(j), @var{y}(i), @var{z}(i,j)). Thus,
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
25 ## columns of @var{z} correspond to different @var{x} values and rows of
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
26 ## @var{z} correspond to different @var{y} values.
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
27 ## @seealso{meshgrid, mesh, contour}
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
28 ## @end deftypefn
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
29
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
30 function retval = meshz (varargin)
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
31
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
32 [h, varargin, nargin] = __plt_get_axis_arg__ ("meshz", varargin{:});
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
33
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
34 ioff = nargin + 1;
7216
5389a52df87b [project @ 2007-11-29 19:07:29 by jwe]
jwe
parents: 7215
diff changeset
35 for i = 1:nargin
7208
a730e47fda4d [project @ 2007-11-28 02:32:41 by jwe]
jwe
parents: 7207
diff changeset
36 if (ischar (varargin{i}))
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
37 ioff = i;
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
38 break;
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
39 endif
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
40 endfor
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
41
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
42 ## Bundle C matrix back into varargin
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
43 if (ioff == 3 || ioff == 5)
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
44 ioff --;
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
45 endif
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
46
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
47 if (ioff == 2)
7208
a730e47fda4d [project @ 2007-11-28 02:32:41 by jwe]
jwe
parents: 7207
diff changeset
48 z = varargin{1};
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
49 [m, n] = size (z);
7216
5389a52df87b [project @ 2007-11-29 19:07:29 by jwe]
jwe
parents: 7215
diff changeset
50 x = 1:n;
5389a52df87b [project @ 2007-11-29 19:07:29 by jwe]
jwe
parents: 7215
diff changeset
51 y = (1:m).';
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
52 else
7208
a730e47fda4d [project @ 2007-11-28 02:32:41 by jwe]
jwe
parents: 7207
diff changeset
53 x = varargin{1};
a730e47fda4d [project @ 2007-11-28 02:32:41 by jwe]
jwe
parents: 7207
diff changeset
54 y = varargin{2};
a730e47fda4d [project @ 2007-11-28 02:32:41 by jwe]
jwe
parents: 7207
diff changeset
55 z = varargin{3};
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
56 endif
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
57
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
58
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
59 if (isvector (x) && isvector (y))
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
60 x = [x(1), x(:).', x(end)];
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
61 y = [y(1); y(:); y(end)];
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
62 else
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
63 x = [x(1, 1), x(1, :), x(1, end);
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 7216
diff changeset
64 x(:, 1), x, x(:, end);
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
65 x(end, 1), x(end, :), x(end, end)];
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
66 y = [y(1, 1), y(1, :), y(1, end);
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 7216
diff changeset
67 y(:, 1), y, y(:, end);
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
68 y(end, 1), y(end, :), y(end, end)];
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
69 endif
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
70
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
71 zref = min (z(isfinite (z)));
14872
c2dbdeaa25df maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents: 14868
diff changeset
72 z = [zref .* ones(1, columns(z) + 2);
c2dbdeaa25df maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents: 14868
diff changeset
73 zref .* ones(rows(z), 1), z, zref .* ones(rows(z), 1);
c2dbdeaa25df maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents: 14868
diff changeset
74 zref.* ones(1, columns(z) + 2)];
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
75
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
76 oldh = gca ();
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
77 unwind_protect
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
78 axes (h);
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
79 tmp = mesh (x, y, z, varargin{ioff:end});
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
80 unwind_protect_cleanup
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
81 axes (oldh);
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
82 end_unwind_protect
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
83
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
84 if (nargout > 0)
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
85 retval = tmp;
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
86 endif
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
87
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents:
diff changeset
88 endfunction