annotate scripts/plot/util/ndgrid.m @ 20368:7503499a252b stable

doc: Update docstrings to have one sentence summary as first line. Update scripts in audio, elfun, general, geometry, and image directories. * scripts/audio/@audioplayer/__get_properties__.m, scripts/audio/@audioplayer/audioplayer.m, scripts/audio/@audioplayer/get.m, scripts/audio/@audioplayer/isplaying.m, scripts/audio/@audioplayer/play.m, scripts/audio/@audioplayer/playblocking.m, scripts/audio/@audioplayer/set.m, scripts/audio/@audioplayer/subsasgn.m, scripts/audio/@audioplayer/subsref.m, scripts/audio/@audiorecorder/audiorecorder.m, scripts/audio/@audiorecorder/get.m, scripts/audio/@audiorecorder/getaudiodata.m, scripts/audio/@audiorecorder/getplayer.m, scripts/audio/@audiorecorder/isrecording.m, scripts/audio/@audiorecorder/play.m, scripts/audio/@audiorecorder/record.m, scripts/audio/@audiorecorder/recordblocking.m, scripts/audio/@audiorecorder/set.m, scripts/audio/@audiorecorder/stop.m, scripts/audio/@audiorecorder/subsasgn.m, scripts/audio/@audiorecorder/subsref.m, scripts/audio/lin2mu.m, scripts/audio/mu2lin.m, scripts/audio/record.m, scripts/audio/sound.m, scripts/audio/soundsc.m, scripts/audio/wavread.m, scripts/audio/wavwrite.m, scripts/elfun/cosd.m, scripts/elfun/sind.m, scripts/elfun/tand.m, scripts/general/accumarray.m, scripts/general/accumdim.m, scripts/general/bitcmp.m, scripts/general/bitget.m, scripts/general/bitset.m, scripts/general/blkdiag.m, scripts/general/cart2pol.m, scripts/general/cart2sph.m, scripts/general/cell2mat.m, scripts/general/celldisp.m, scripts/general/chop.m, scripts/general/circshift.m, scripts/general/common_size.m, scripts/general/cplxpair.m, scripts/general/cumtrapz.m, scripts/general/dblquad.m, scripts/general/deal.m, scripts/general/del2.m, scripts/general/display.m, scripts/general/divergence.m, scripts/general/fieldnames.m, scripts/general/flip.m, scripts/general/flipdim.m, scripts/general/fliplr.m, scripts/general/flipud.m, scripts/general/gradient.m, scripts/general/interp3.m, scripts/general/interpft.m, scripts/general/interpn.m, scripts/general/loadobj.m, scripts/general/logspace.m, scripts/general/methods.m, scripts/general/nargchk.m, scripts/general/narginchk.m, scripts/general/nargoutchk.m, scripts/general/nextpow2.m, scripts/general/nthargout.m, scripts/general/num2str.m, scripts/general/pol2cart.m, scripts/general/polyarea.m, scripts/general/postpad.m, scripts/general/prepad.m, scripts/general/profile.m, scripts/general/quadgk.m, scripts/general/quadl.m, scripts/general/quadv.m, scripts/general/randi.m, scripts/general/rat.m, scripts/general/repmat.m, scripts/general/rot90.m, scripts/general/rotdim.m, scripts/general/saveobj.m, scripts/general/shift.m, scripts/general/shiftdim.m, scripts/general/sortrows.m, scripts/general/sph2cart.m, scripts/general/structfun.m, scripts/general/subsindex.m, scripts/general/trapz.m, scripts/general/triplequad.m, scripts/geometry/delaunayn.m, scripts/geometry/dsearch.m, scripts/geometry/dsearchn.m, scripts/geometry/griddata.m, scripts/geometry/griddata3.m, scripts/geometry/griddatan.m, scripts/geometry/inpolygon.m, scripts/geometry/rectint.m, scripts/geometry/tsearchn.m, scripts/geometry/voronoi.m, scripts/geometry/voronoin.m, scripts/help/__unimplemented__.m, scripts/help/doc.m, scripts/help/doc_cache_create.m, scripts/help/get_first_help_sentence.m, scripts/help/help.m, scripts/help/lookfor.m, scripts/help/print_usage.m, scripts/help/type.m, scripts/help/which.m, scripts/image/autumn.m, scripts/image/bone.m, scripts/image/brighten.m, scripts/image/cmpermute.m, scripts/image/colorcube.m, scripts/image/contrast.m, scripts/image/cool.m, scripts/image/copper.m, scripts/image/cubehelix.m, scripts/image/flag.m, scripts/image/gmap40.m, scripts/image/gray.m, scripts/image/gray2ind.m, scripts/image/hot.m, scripts/image/hsv.m, scripts/image/image.m, scripts/image/imagesc.m, scripts/image/imfinfo.m, scripts/image/imformats.m, scripts/image/imread.m, scripts/image/imshow.m, scripts/image/imwrite.m, scripts/image/iscolormap.m, scripts/image/jet.m, scripts/image/lines.m, scripts/image/ntsc2rgb.m, scripts/image/ocean.m, scripts/image/pink.m, scripts/image/prism.m, scripts/image/rainbow.m, scripts/image/rgb2ntsc.m, scripts/image/spinmap.m, scripts/image/spring.m, scripts/image/summer.m, scripts/image/white.m, scripts/image/winter.m: Update docstrings to have one sentence summary as first line. Re-structure to have line lengths <= 80 chars.
author Rik <rik@octave.org>
date Sun, 03 May 2015 09:36:20 -0700
parents 9fc020886ae9
children 777f26aa8e3e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19898
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 17902
diff changeset
1 ## Copyright (C) 2006-2015 Alexander Barth
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
2 ##
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
4 ##
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
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: 6895
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: 6895
diff changeset
8 ## your option) any later version.
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
9 ##
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
14 ##
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
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: 6895
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: 6895
diff changeset
17 ## <http://www.gnu.org/licenses/>.
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
18
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 9040
diff changeset
20 ## @deftypefn {Function File} {[@var{y1}, @var{y2}, @dots{}, @var{y}n] =} ndgrid (@var{x1}, @var{x2}, @dots{}, @var{x}n)
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 9040
diff changeset
21 ## @deftypefnx {Function File} {[@var{y1}, @var{y2}, @dots{}, @var{y}n] =} ndgrid (@var{x})
17495
db92cd6117a9 ndgrid.m: Add explanation of differences with meshgrid to docstring.
Rik <rik@octave.org>
parents: 16778
diff changeset
22 ## Given n vectors @var{x1}, @dots{}, @var{x}n, @code{ndgrid} returns
14373
d00900b3dc4b doc: Use two spaces at start of sentence.
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
23 ## n arrays of dimension n. The elements of the i-th output argument
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6547
diff changeset
24 ## contains the elements of the vector @var{x}i repeated over all
8494
836618fee9d6 [docs] add hyphen
Brian Gough <bjg@gnu.org>
parents: 8455
diff changeset
25 ## dimensions different from the i-th dimension. Calling ndgrid with
17495
db92cd6117a9 ndgrid.m: Add explanation of differences with meshgrid to docstring.
Rik <rik@octave.org>
parents: 16778
diff changeset
26 ## only one input argument @var{x} is equivalent to calling ndgrid with
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
27 ## all n input arguments equal to @var{x}:
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
28 ##
14373
d00900b3dc4b doc: Use two spaces at start of sentence.
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
29 ## [@var{y1}, @var{y2}, @dots{}, @var{y}n] = ndgrid (@var{x}, @dots{}, @var{x})
17495
db92cd6117a9 ndgrid.m: Add explanation of differences with meshgrid to docstring.
Rik <rik@octave.org>
parents: 16778
diff changeset
30 ##
db92cd6117a9 ndgrid.m: Add explanation of differences with meshgrid to docstring.
Rik <rik@octave.org>
parents: 16778
diff changeset
31 ## Programming Note: @code{ndgrid} is very similar to the function
db92cd6117a9 ndgrid.m: Add explanation of differences with meshgrid to docstring.
Rik <rik@octave.org>
parents: 16778
diff changeset
32 ## @code{meshgrid} except that the first two dimensions are transposed in
db92cd6117a9 ndgrid.m: Add explanation of differences with meshgrid to docstring.
Rik <rik@octave.org>
parents: 16778
diff changeset
33 ## comparison to @code{meshgrid}. Some core functions expect @code{meshgrid}
db92cd6117a9 ndgrid.m: Add explanation of differences with meshgrid to docstring.
Rik <rik@octave.org>
parents: 16778
diff changeset
34 ## input and others expect @code{ndgrid} input. Check the documentation for
db92cd6117a9 ndgrid.m: Add explanation of differences with meshgrid to docstring.
Rik <rik@octave.org>
parents: 16778
diff changeset
35 ## the function in question to determine the proper input format.
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
36 ## @seealso{meshgrid}
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
37 ## @end deftypefn
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
38
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
39 ## Author: Alexander Barth <abarth@marine.usf.edu>
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
40
5838
376e02b2ce70 [project @ 2006-06-01 20:23:53 by jwe]
jwe
parents: 5837
diff changeset
41 function varargout = ndgrid (varargin)
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
42
16778
e205f5ea826a ndgrid.m: Fix Matlab incompatibility with null inputs (bug #38685).
Rik <rik@octave.org>
parents: 16675
diff changeset
43 if (nargin == 0)
e205f5ea826a ndgrid.m: Fix Matlab incompatibility with null inputs (bug #38685).
Rik <rik@octave.org>
parents: 16675
diff changeset
44 print_usage ();
e205f5ea826a ndgrid.m: Fix Matlab incompatibility with null inputs (bug #38685).
Rik <rik@octave.org>
parents: 16675
diff changeset
45 elseif (nargin == 1)
17902
9bcf1614cd80 ndgrid.m: Don't call reshape with a single dimension input.
Rik <rik@octave.org>
parents: 17744
diff changeset
46 nd = max (nargout, 1);
9bcf1614cd80 ndgrid.m: Don't call reshape with a single dimension input.
Rik <rik@octave.org>
parents: 17744
diff changeset
47 ## If only one input argument is given, repeat it nd-times
9bcf1614cd80 ndgrid.m: Don't call reshape with a single dimension input.
Rik <rik@octave.org>
parents: 17744
diff changeset
48 varargin(1:nd) = varargin(1);
16778
e205f5ea826a ndgrid.m: Fix Matlab incompatibility with null inputs (bug #38685).
Rik <rik@octave.org>
parents: 16675
diff changeset
49 elseif (nargin >= nargout)
17902
9bcf1614cd80 ndgrid.m: Don't call reshape with a single dimension input.
Rik <rik@octave.org>
parents: 17744
diff changeset
50 nd = max (nargin, 1);
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
51 else
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
52 error ("ndgrid: wrong number of input arguments");
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
53 endif
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
54
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
55 ## Determine the size of the output arguments
17902
9bcf1614cd80 ndgrid.m: Don't call reshape with a single dimension input.
Rik <rik@octave.org>
parents: 17744
diff changeset
56 shape = zeros (1, nd);
9bcf1614cd80 ndgrid.m: Don't call reshape with a single dimension input.
Rik <rik@octave.org>
parents: 17744
diff changeset
57 for i = 1:nd
16778
e205f5ea826a ndgrid.m: Fix Matlab incompatibility with null inputs (bug #38685).
Rik <rik@octave.org>
parents: 16675
diff changeset
58 if (! isvector (varargin{i}) && ! isempty (varargin{i}))
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
59 error ("ndgrid: arguments must be vectors");
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
60 endif
5838
376e02b2ce70 [project @ 2006-06-01 20:23:53 by jwe]
jwe
parents: 5837
diff changeset
61 shape(i) = length (varargin{i});
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
62 endfor
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
63
17902
9bcf1614cd80 ndgrid.m: Don't call reshape with a single dimension input.
Rik <rik@octave.org>
parents: 17744
diff changeset
64 if (nd == 1)
9bcf1614cd80 ndgrid.m: Don't call reshape with a single dimension input.
Rik <rik@octave.org>
parents: 17744
diff changeset
65 ## Special case, single input vector
9bcf1614cd80 ndgrid.m: Don't call reshape with a single dimension input.
Rik <rik@octave.org>
parents: 17744
diff changeset
66 varargout{1} = varargin{1}(:);
9bcf1614cd80 ndgrid.m: Don't call reshape with a single dimension input.
Rik <rik@octave.org>
parents: 17744
diff changeset
67 else
9bcf1614cd80 ndgrid.m: Don't call reshape with a single dimension input.
Rik <rik@octave.org>
parents: 17744
diff changeset
68 for i = 1:nd
9bcf1614cd80 ndgrid.m: Don't call reshape with a single dimension input.
Rik <rik@octave.org>
parents: 17744
diff changeset
69 ## size for reshape
9bcf1614cd80 ndgrid.m: Don't call reshape with a single dimension input.
Rik <rik@octave.org>
parents: 17744
diff changeset
70 r = ones (1, nd+1);
9bcf1614cd80 ndgrid.m: Don't call reshape with a single dimension input.
Rik <rik@octave.org>
parents: 17744
diff changeset
71 r(i) = shape(i);
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
72
17902
9bcf1614cd80 ndgrid.m: Don't call reshape with a single dimension input.
Rik <rik@octave.org>
parents: 17744
diff changeset
73 ## size for repmat
9bcf1614cd80 ndgrid.m: Don't call reshape with a single dimension input.
Rik <rik@octave.org>
parents: 17744
diff changeset
74 s = shape;
9bcf1614cd80 ndgrid.m: Don't call reshape with a single dimension input.
Rik <rik@octave.org>
parents: 17744
diff changeset
75 s(i) = 1;
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
76
17902
9bcf1614cd80 ndgrid.m: Don't call reshape with a single dimension input.
Rik <rik@octave.org>
parents: 17744
diff changeset
77 varargout{i} = repmat (reshape (varargin{i}, r), s);
9bcf1614cd80 ndgrid.m: Don't call reshape with a single dimension input.
Rik <rik@octave.org>
parents: 17744
diff changeset
78 endfor
9bcf1614cd80 ndgrid.m: Don't call reshape with a single dimension input.
Rik <rik@octave.org>
parents: 17744
diff changeset
79 endif
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
80
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
81 endfunction
13263
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
82
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
83
13263
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
84 %!test
16675
558e1ce7247b handle single output case of ndgrid
Clemens Buchacher <drizzd@aon.at>
parents: 14373
diff changeset
85 %! x = 1:3;
558e1ce7247b handle single output case of ndgrid
Clemens Buchacher <drizzd@aon.at>
parents: 14373
diff changeset
86 %! assert (isequal (ndgrid (x), x(:)));
558e1ce7247b handle single output case of ndgrid
Clemens Buchacher <drizzd@aon.at>
parents: 14373
diff changeset
87
558e1ce7247b handle single output case of ndgrid
Clemens Buchacher <drizzd@aon.at>
parents: 14373
diff changeset
88 %!test
558e1ce7247b handle single output case of ndgrid
Clemens Buchacher <drizzd@aon.at>
parents: 14373
diff changeset
89 %! x = 1:3;
558e1ce7247b handle single output case of ndgrid
Clemens Buchacher <drizzd@aon.at>
parents: 14373
diff changeset
90 %! [XX, YY] = ndgrid (x);
558e1ce7247b handle single output case of ndgrid
Clemens Buchacher <drizzd@aon.at>
parents: 14373
diff changeset
91 %! assert (size_equal (XX, YY));
558e1ce7247b handle single output case of ndgrid
Clemens Buchacher <drizzd@aon.at>
parents: 14373
diff changeset
92 %! assert (isequal (XX, repmat(x(:), 1, numel(x))));
558e1ce7247b handle single output case of ndgrid
Clemens Buchacher <drizzd@aon.at>
parents: 14373
diff changeset
93 %! assert (isequal (YY, repmat(x, numel(x), 1)));
558e1ce7247b handle single output case of ndgrid
Clemens Buchacher <drizzd@aon.at>
parents: 14373
diff changeset
94
558e1ce7247b handle single output case of ndgrid
Clemens Buchacher <drizzd@aon.at>
parents: 14373
diff changeset
95 %!test
13263
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
96 %! x = 1:2;
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
97 %! y = 1:3;
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
98 %! z = 1:4;
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
99 %! [XX, YY, ZZ] = ndgrid (x, y, z);
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
100 %! assert (size_equal (XX, YY, ZZ));
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
101 %! assert (ndims (XX), 3);
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
102 %! assert (size (XX), [2, 3, 4]);
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
103 %! 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: 11587
diff changeset
104 %! 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: 11587
diff changeset
105
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
106 %!test
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
107 %! x = 1:2;
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
108 %! y = 1:3;
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
109 %! [XX1, YY1] = meshgrid (x, y);
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
110 %! [XX2, YY2] = ndgrid (x, y);
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
111 %! assert (size_equal (XX1, YY1));
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
112 %! assert (size_equal (XX2, YY2));
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
113 %! assert (ndims (XX1), 2);
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
114 %! assert (size (XX1), [3, 2]);
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
115 %! assert (size (XX2), [2, 3]);
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
116 %! assert (XX2(1) * YY2(1), x(1) * y(1));
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
117 %! assert (XX2(end) * YY2(end), x(end) * y(end));
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
118 %! assert (XX1, XX2.');
a156263b5509 Add tests for meshgrid and ndgrid.
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
119 %! assert (YY1, YY2.');
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
120
16778
e205f5ea826a ndgrid.m: Fix Matlab incompatibility with null inputs (bug #38685).
Rik <rik@octave.org>
parents: 16675
diff changeset
121 %!assert (ndgrid ([]), zeros(0,1))
e205f5ea826a ndgrid.m: Fix Matlab incompatibility with null inputs (bug #38685).
Rik <rik@octave.org>
parents: 16675
diff changeset
122 %!assert (ndgrid ([], []), zeros(0,0))
e205f5ea826a ndgrid.m: Fix Matlab incompatibility with null inputs (bug #38685).
Rik <rik@octave.org>
parents: 16675
diff changeset
123
20038
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19898
diff changeset
124 ## Test input validation
16778
e205f5ea826a ndgrid.m: Fix Matlab incompatibility with null inputs (bug #38685).
Rik <rik@octave.org>
parents: 16675
diff changeset
125 %!error ndgrid ()
e205f5ea826a ndgrid.m: Fix Matlab incompatibility with null inputs (bug #38685).
Rik <rik@octave.org>
parents: 16675
diff changeset
126 %!error <wrong number of input arguments> [a,b,c] = ndgrid (1:3,1:3)
e205f5ea826a ndgrid.m: Fix Matlab incompatibility with null inputs (bug #38685).
Rik <rik@octave.org>
parents: 16675
diff changeset
127 %!error <arguments must be vectors> ndgrid (ones (2,2))
e205f5ea826a ndgrid.m: Fix Matlab incompatibility with null inputs (bug #38685).
Rik <rik@octave.org>
parents: 16675
diff changeset
128