Mercurial > hg > octave-lyh
diff src/data.cc @ 4554:78e34346f6fd
[project @ 2003-10-27 22:01:49 by jwe]
author | jwe |
---|---|
date | Mon, 27 Oct 2003 22:01:49 +0000 |
parents | c16f153836a0 |
children | 773a21e4fce8 |
line wrap: on
line diff
--- a/src/data.cc +++ b/src/data.cc @@ -688,6 +688,29 @@ return retval; } +DEFUN (ndims, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} ndims (@var{a})\n\ +Returns the number of dimensions of array @var{a}.\n\ +For any array, the result will always be larger than or equal to 2.\n\ +Trailing singleton dimensions are not counted.\n\ +@end deftypefn") +{ + octave_value retval; + + if (args.length () == 1) + { + int n_dims = args(0).ndims (); + + if (! error_state) + retval = n_dims; + } + else + print_usage ("ndims"); + + return retval; +} + DEFUN (size, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} size (@var{a}, @var{n})\n\