annotate scripts/plot/meshgrid.m @ 17126:eaab03308c0b

doc: Rewrite docstrings for most plot functions. Emphasize clarity, use common "voice", and increase density of seealso links. * doc/interpreter/plot.txi: Add @findex entries that were in xlim.m * scripts/miscellaneous/getappdata.m scripts/miscellaneous/setappdata.m, scripts/plot/allchild.m, scripts/plot/ancestor.m, scripts/plot/area.m, scripts/plot/axes.m, scripts/plot/axis.m, scripts/plot/bar.m, scripts/plot/barh.m, scripts/plot/box.m, scripts/plot/caxis.m, scripts/plot/cla.m, scripts/plot/clabel.m, scripts/plot/clf.m, scripts/plot/close.m, scripts/plot/closereq.m, scripts/plot/colorbar.m, scripts/plot/comet.m, scripts/plot/comet3.m, scripts/plot/compass.m, scripts/plot/contour.m, scripts/plot/contour3.m, scripts/plot/contourc.m, scripts/plot/contourf.m, scripts/plot/copyobj.m, scripts/plot/cylinder.m, scripts/plot/daspect.m, scripts/plot/diffuse.m, scripts/plot/ellipsoid.m, scripts/plot/errorbar.m, scripts/plot/ezcontour.m, scripts/plot/ezcontourf.m, scripts/plot/ezmesh.m, scripts/plot/ezmeshc.m, scripts/plot/ezplot.m, scripts/plot/ezplot3.m, scripts/plot/ezpolar.m, scripts/plot/ezsurf.m, scripts/plot/ezsurfc.m, scripts/plot/feather.m, scripts/plot/figure.m, scripts/plot/fill.m, scripts/plot/findall.m, scripts/plot/findobj.m, scripts/plot/fplot.m, scripts/plot/gca.m, scripts/plot/gcbf.m, scripts/plot/gcbo.m, scripts/plot/gcf.m, scripts/plot/gco.m, scripts/plot/ginput.m, scripts/plot/graphics_toolkit.m, scripts/plot/grid.m, scripts/plot/gtext.m, scripts/plot/guidata.m, scripts/plot/guihandles.m, scripts/plot/hdl2struct.m, scripts/plot/hggroup.m, scripts/plot/hidden.m, scripts/plot/hist.m, scripts/plot/hold.m, scripts/plot/ishghandle.m, scripts/plot/ishold.m, scripts/plot/isocolors.m, scripts/plot/isprop.m, scripts/plot/legend.m, scripts/plot/line.m, scripts/plot/linkprop.m, scripts/plot/loglog.m, scripts/plot/loglogerr.m, scripts/plot/mesh.m, scripts/plot/meshc.m, scripts/plot/meshgrid.m, scripts/plot/meshz.m, scripts/plot/newplot.m, scripts/plot/orient.m, scripts/plot/pareto.m, scripts/plot/patch.m, scripts/plot/pcolor.m, scripts/plot/peaks.m, scripts/plot/pie.m, scripts/plot/pie3.m, scripts/plot/plot.m, scripts/plot/plot3.m, scripts/plot/plotmatrix.m, scripts/plot/plotyy.m, scripts/plot/polar.m, scripts/plot/print.m, scripts/plot/quiver.m, scripts/plot/quiver3.m, scripts/plot/rectangle.m, scripts/plot/refresh.m, scripts/plot/refreshdata.m, scripts/plot/ribbon.m, scripts/plot/rose.m, scripts/plot/saveas.m, scripts/plot/scatter.m, scripts/plot/scatter3.m, scripts/plot/semilogx.m, scripts/plot/semilogxerr.m, scripts/plot/semilogy.m, scripts/plot/semilogyerr.m, scripts/plot/shading.m, scripts/plot/shg.m, scripts/plot/shrinkfaces.m, scripts/plot/slice.m, scripts/plot/specular.m, scripts/plot/sphere.m, scripts/plot/stairs.m, scripts/plot/stem.m, scripts/plot/stem3.m, scripts/plot/struct2hdl.m, scripts/plot/subplot.m, scripts/plot/surf.m, scripts/plot/surface.m, scripts/plot/surfc.m, scripts/plot/surfl.m, scripts/plot/tetramesh.m, scripts/plot/text.m, scripts/plot/title.m, scripts/plot/trimesh.m, scripts/plot/triplot.m, scripts/plot/trisurf.m, scripts/plot/view.m, scripts/plot/waitbar.m, scripts/plot/waitforbuttonpress.m, scripts/plot/waterfall.m, scripts/plot/whitebg.m, scripts/plot/xlabel.m, scripts/plot/xlim.m, scripts/plot/ylabel.m, scripts/plot/ylim.m, scripts/plot/zlabel.m, scripts/plot/zlim.m: Rewrite docstrings for most plot functions. Emphasize clarity, use common "voice", and increase density of seealso links.
author Rik <rik@octave.org>
date Wed, 31 Jul 2013 13:53:30 -0700
parents f3d52523cde1
children cff399332a7f
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: 13263
diff changeset
1 ## Copyright (C) 1996-2012 John W. Eaton
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
2 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
3 ## This file is part of Octave.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
4 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6813
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6813
diff changeset
8 ## your option) any later version.
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
9 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
13 ## General Public License for more details.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
14 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6813
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6813
diff changeset
17 ## <http://www.gnu.org/licenses/>.
1713
d9e42d0bab09 [project @ 1996-01-08 02:22:55 by jwe]
jwe
parents:
diff changeset
18
3407
5e0a0b1cba43 [project @ 2000-01-06 03:13:55 by jwe]
jwe
parents: 2847
diff changeset
19 ## -*- texinfo -*-
17126
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14363
diff changeset
20 ## @deftypefn {Function File} {[@var{xx}, @var{yy}] =} meshgrid (@var{x}, @var{y})
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14363
diff changeset
21 ## @deftypefnx {Function File} {[@var{xx}, @var{yy}, @var{zz}] =} meshgrid (@var{x}, @var{y}, @var{z})
3439
3234a698073a [project @ 2000-01-14 09:51:14 by jwe]
jwe
parents: 3408
diff changeset
22 ## @deftypefnx {Function File} {[@var{xx}, @var{yy}] =} meshgrid (@var{x})
17126
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14363
diff changeset
23 ## @deftypefnx {Function File} {[@var{xx}, @var{yy}, @var{zz}] =} meshgrid (@var{x})
5717
34cda7d94c08 [project @ 2006-03-27 22:26:18 by jwe]
jwe
parents: 5642
diff changeset
24 ## Given vectors of @var{x} and @var{y} and @var{z} coordinates, and
9209
923c7cb7f13f Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents: 7017
diff changeset
25 ## returning 3 arguments, return three-dimensional arrays corresponding
5717
34cda7d94c08 [project @ 2006-03-27 22:26:18 by jwe]
jwe
parents: 5642
diff changeset
26 ## to the @var{x}, @var{y}, and @var{z} coordinates of a mesh. When
34cda7d94c08 [project @ 2006-03-27 22:26:18 by jwe]
jwe
parents: 5642
diff changeset
27 ## returning only 2 arguments, return matrices corresponding to the
34cda7d94c08 [project @ 2006-03-27 22:26:18 by jwe]
jwe
parents: 5642
diff changeset
28 ## @var{x} and @var{y} coordinates of a mesh. The rows of @var{xx} are
34cda7d94c08 [project @ 2006-03-27 22:26:18 by jwe]
jwe
parents: 5642
diff changeset
29 ## copies of @var{x}, and the columns of @var{yy} are copies of @var{y}.
34cda7d94c08 [project @ 2006-03-27 22:26:18 by jwe]
jwe
parents: 5642
diff changeset
30 ## If @var{y} is omitted, then it is assumed to be the same as @var{x},
34cda7d94c08 [project @ 2006-03-27 22:26:18 by jwe]
jwe
parents: 5642
diff changeset
31 ## and @var{z} is assumed the same as @var{y}.
17126
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14363
diff changeset
32 ## @seealso{ndgrid, mesh, contour, surf}
3407
5e0a0b1cba43 [project @ 2000-01-06 03:13:55 by jwe]
jwe
parents: 2847
diff changeset
33 ## @end deftypefn
1713
d9e42d0bab09 [project @ 1996-01-08 02:22:55 by jwe]
jwe
parents:
diff changeset
34
2314
949ab8eba8bc [project @ 1996-07-12 03:58:02 by jwe]
jwe
parents: 2313
diff changeset
35 ## Author: jwe
949ab8eba8bc [project @ 1996-07-12 03:58:02 by jwe]
jwe
parents: 2313
diff changeset
36
5378
b2a5596a3f7b [project @ 2005-06-02 16:01:25 by jwe]
jwe
parents: 5307
diff changeset
37 function [xx, yy, zz] = meshgrid (x, y, z)
1713
d9e42d0bab09 [project @ 1996-01-08 02:22:55 by jwe]
jwe
parents:
diff changeset
38
5717
34cda7d94c08 [project @ 2006-03-27 22:26:18 by jwe]
jwe
parents: 5642
diff changeset
39 if (nargin == 0 || nargin > 3)
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5717
diff changeset
40 print_usage ();
5717
34cda7d94c08 [project @ 2006-03-27 22:26:18 by jwe]
jwe
parents: 5642
diff changeset
41 endif
34cda7d94c08 [project @ 2006-03-27 22:26:18 by jwe]
jwe
parents: 5642
diff changeset
42
34cda7d94c08 [project @ 2006-03-27 22:26:18 by jwe]
jwe
parents: 5642
diff changeset
43 if (nargin < 2)
1713
d9e42d0bab09 [project @ 1996-01-08 02:22:55 by jwe]
jwe
parents:
diff changeset
44 y = x;
d9e42d0bab09 [project @ 1996-01-08 02:22:55 by jwe]
jwe
parents:
diff changeset
45 endif
5717
34cda7d94c08 [project @ 2006-03-27 22:26:18 by jwe]
jwe
parents: 5642
diff changeset
46
6813
75d99621f850 [project @ 2007-08-14 17:14:18 by jwe]
jwe
parents: 6046
diff changeset
47 ## Use repmat to ensure that the result values have the same type as
75d99621f850 [project @ 2007-08-14 17:14:18 by jwe]
jwe
parents: 6046
diff changeset
48 ## the arguments.
75d99621f850 [project @ 2007-08-14 17:14:18 by jwe]
jwe
parents: 6046
diff changeset
49
5717
34cda7d94c08 [project @ 2006-03-27 22:26:18 by jwe]
jwe
parents: 5642
diff changeset
50 if (nargout < 3)
4030
22bd65326ec1 [project @ 2002-08-09 18:58:13 by jwe]
jwe
parents: 3803
diff changeset
51 if (isvector (x) && isvector (y))
6813
75d99621f850 [project @ 2007-08-14 17:14:18 by jwe]
jwe
parents: 6046
diff changeset
52 xx = repmat (x(:).', length (y), 1);
75d99621f850 [project @ 2007-08-14 17:14:18 by jwe]
jwe
parents: 6046
diff changeset
53 yy = repmat (y(:), 1, length (x));
1713
d9e42d0bab09 [project @ 1996-01-08 02:22:55 by jwe]
jwe
parents:
diff changeset
54 else
d9e42d0bab09 [project @ 1996-01-08 02:22:55 by jwe]
jwe
parents:
diff changeset
55 error ("meshgrid: arguments must be vectors");
d9e42d0bab09 [project @ 1996-01-08 02:22:55 by jwe]
jwe
parents:
diff changeset
56 endif
d9e42d0bab09 [project @ 1996-01-08 02:22:55 by jwe]
jwe
parents:
diff changeset
57 else
5717
34cda7d94c08 [project @ 2006-03-27 22:26:18 by jwe]
jwe
parents: 5642
diff changeset
58 if (nargin < 3)
34cda7d94c08 [project @ 2006-03-27 22:26:18 by jwe]
jwe
parents: 5642
diff changeset
59 z = y;
34cda7d94c08 [project @ 2006-03-27 22:26:18 by jwe]
jwe
parents: 5642
diff changeset
60 endif
34cda7d94c08 [project @ 2006-03-27 22:26:18 by jwe]
jwe
parents: 5642
diff changeset
61 if (isvector (x) && isvector (y) && isvector (z))
34cda7d94c08 [project @ 2006-03-27 22:26:18 by jwe]
jwe
parents: 5642
diff changeset
62 lenx = length (x);
34cda7d94c08 [project @ 2006-03-27 22:26:18 by jwe]
jwe
parents: 5642
diff changeset
63 leny = length (y);
34cda7d94c08 [project @ 2006-03-27 22:26:18 by jwe]
jwe
parents: 5642
diff changeset
64 lenz = length (z);
6813
75d99621f850 [project @ 2007-08-14 17:14:18 by jwe]
jwe
parents: 6046
diff changeset
65 xx = repmat (repmat (x(:).', leny, 1), [1, 1, lenz]);
75d99621f850 [project @ 2007-08-14 17:14:18 by jwe]
jwe
parents: 6046
diff changeset
66 yy = repmat (repmat (y(:), 1, lenx), [1, 1, lenz]);
5717
34cda7d94c08 [project @ 2006-03-27 22:26:18 by jwe]
jwe
parents: 5642
diff changeset
67 zz = reshape (repmat (z(:).', lenx*leny, 1)(:), leny, lenx, lenz);
34cda7d94c08 [project @ 2006-03-27 22:26:18 by jwe]
jwe
parents: 5642
diff changeset
68 else
6813
75d99621f850 [project @ 2007-08-14 17:14:18 by jwe]
jwe
parents: 6046
diff changeset
69 error ("meshgrid: arguments must be vectors");
5717
34cda7d94c08 [project @ 2006-03-27 22:26:18 by jwe]
jwe
parents: 5642
diff changeset
70 endif
1713
d9e42d0bab09 [project @ 1996-01-08 02:22:55 by jwe]
jwe
parents:
diff changeset
71 endif
d9e42d0bab09 [project @ 1996-01-08 02:22:55 by jwe]
jwe
parents:
diff changeset
72
d9e42d0bab09 [project @ 1996-01-08 02:22:55 by jwe]
jwe
parents:
diff changeset
73 endfunction
13263
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
74
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
75
13263
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
76 %!test
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
77 %! x = 1:2;
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
78 %! y = 1:3;
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
79 %! z = 1:4;
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
80 %! [XX, YY, ZZ] = meshgrid (x, y, z);
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
81 %! assert (size_equal (XX, YY, ZZ));
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
82 %! assert (ndims (XX), 3);
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
83 %! assert (size (XX), [3, 2, 4]);
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
84 %! assert (XX(1) * YY(1) * ZZ(1), x(1) * y(1) * z(1));
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
85 %! assert (XX(end) * YY(end) * ZZ(end), x(end) * y(end) * z(end));
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
86
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
87 %!test
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
88 %! x = 1:2;
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
89 %! y = 1:3;
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
90 %! [XX, YY] = meshgrid (x, y);
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
91 %! assert (size_equal (XX, YY));
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
92 %! assert (ndims (XX), 2);
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
93 %! assert (size (XX), [3, 2]);
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
94 %! assert (XX(1) * YY(1), x(1) * y(1));
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
95 %! assert (XX(end) * YY(end), x(end) * y(end));
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
96
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
97 %!test
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
98 %! x = 1:3;
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
99 %! [XX1, YY1] = meshgrid (x, x);
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
100 %! [XX2, YY2] = meshgrid (x);
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
101 %! assert (size_equal (XX1, XX2, YY1, YY2));
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
102 %! assert (ndims (XX1), 2);
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
103 %! assert (size (XX1), [3, 3]);
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11523
diff changeset
104 %! assert (XX1, XX2);
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
105 %! assert (YY1, YY2);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
106