# HG changeset patch # User John W. Eaton # Date 1361406581 18000 # Node ID 39129305b914ef480e7908a861f66d8cb1b30cbf # Parent c90c9623b20f297c1404f5f6ccc63f6b8c91216b provide some undocumented matlab behavior for linspace (bug #38151) * data.cc (Flinspace): Accept linspace (a, b, []). diff -r c90c9623b20f -r 39129305b914 libinterp/interpfcn/data.cc --- a/libinterp/interpfcn/data.cc Wed Feb 20 16:11:47 2013 -0800 +++ b/libinterp/interpfcn/data.cc Wed Feb 20 19:29:41 2013 -0500 @@ -4729,7 +4729,17 @@ } if (nargin == 3) - npoints = args(2).idx_type_value (); + { + // Apparently undocumented Matlab. If the third arg is an empty + // numeric value, the number of points defaults to 1. + + octave_value arg_3 = args(2); + + if (arg_3.is_numeric_type () && arg_3.is_empty ()) + npoints = 1; + else + npoints = arg_3.idx_type_value (); + } if (! error_state) { @@ -4770,6 +4780,8 @@ %assert (linspace ([1, 2; 3, 4], 5, 6), linspace (1, 5, 6)) +%assert (linspace (0, 1, []), 1) + %!error linspace () %!error linspace (1, 2, 3, 4) */