Mercurial > hg > octave-lyh
diff scripts/general/linspace.m @ 1098:c0f319a1e51d
[project @ 1995-02-13 16:46:08 by jwe]
author | jwe |
---|---|
date | Mon, 13 Feb 1995 16:46:08 +0000 |
parents | 3f257ab07921 |
children | 6243c37ae2c5 |
line wrap: on
line diff
--- a/scripts/general/linspace.m +++ b/scripts/general/linspace.m @@ -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