changeset 32990:749617dc63eb

maint: merge stable to default
author Rik <rik@octave.org>
date Thu, 08 Feb 2024 11:35:20 -0800
parents 3d62521c7228 (current diff) 9cbd0bbe7bd8 (diff)
children fbed4958bfca b9c6ed013576
files libinterp/corefcn/data.cc
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/data.cc	Thu Feb 08 08:41:23 2024 -0800
+++ b/libinterp/corefcn/data.cc	Thu Feb 08 11:35:20 2024 -0800
@@ -2722,7 +2722,9 @@
 first argument, the number of columns, dimension 2, is returned in the
 second argument, etc.  If there are more dimensions in @var{A} than there are
 output arguments, @code{size} returns the total number of elements in the
-remaining dimensions in the final output argument.
+remaining dimensions in the final output argument.  If the requested dimension
+@var{dim} is greater than the number of dimensions in @var{A}, @code{size}
+returns 1 (not 0).
 
 Example 1: single row vector output
 
@@ -2762,6 +2764,15 @@
 @end group
 @end example
 
+Example 5: number of elements in dimension > number of actual dimensions
+
+@example
+@group
+sz4 = size (ones (2, 3), 4)
+    @result{} sz4 = 1
+@end group
+@end example
+
 @seealso{numel, ndims, length, rows, columns, size_equal, common_size}
 @end deftypefn */)
 {