# HG changeset patch # User jwe # Date 792693968 0 # Node ID c0f319a1e51d9e896932e1463b5b67fe9f32c021 # Parent 3243a4f599379dd900d19dafb715ddb22e573e70 [project @ 1995-02-13 16:46:08 by jwe] diff -r 3243a4f59937 -r c0f319a1e51d scripts/general/linspace.m --- a/scripts/general/linspace.m Mon Feb 13 03:22:28 1995 +0000 +++ b/scripts/general/linspace.m Mon Feb 13 16:46:08 1995 +0000 @@ -45,9 +45,12 @@ error ("linspace: npoints must be greater than 2"); endif +# In some cases x1 + delta * (npoints - 1) will not be equal to x2, so +# we cheat and force the last value to be x2. + if (length (x1) == 1 && length (x2) == 1) delta = (x2 - x1) / (npoints - 1); - retval = x1:delta:x2; + retval = [x1+(0:npoints-2)*delta, x2]; else error ("linspace: arguments must be scalars"); endif