Mercurial > hg > octave-lyh
comparison scripts/general/linspace.m @ 415:0ce34c2fc3d5
[project @ 1994-05-16 18:30:52 by jwe]
author | jwe |
---|---|
date | Mon, 16 May 1994 18:31:31 +0000 |
parents | 16a24e76d6e0 |
children | f8c8c2461f4d |
comparison
equal
deleted
inserted
replaced
414:9a17c682207e | 415:0ce34c2fc3d5 |
---|---|
1 # Copyright (C) 1993 John W. Eaton | 1 # Copyright (C) 1993, 1994 John W. Eaton |
2 # | 2 # |
3 # This file is part of Octave. | 3 # This file is part of Octave. |
4 # | 4 # |
5 # Octave is free software; you can redistribute it and/or modify it | 5 # Octave is free software; you can redistribute it and/or modify it |
6 # under the terms of the GNU General Public License as published by the | 6 # under the terms of the GNU General Public License as published by the |
45 error ("linspace: npoints must be greater than 2"); | 45 error ("linspace: npoints must be greater than 2"); |
46 endif | 46 endif |
47 | 47 |
48 if (length (x1) == 1 && length (x2) == 1) | 48 if (length (x1) == 1 && length (x2) == 1) |
49 delta = (x2 - x1) / (npoints - 1); | 49 delta = (x2 - x1) / (npoints - 1); |
50 retval = zeros (1, npoints); | 50 retval = x1:delta:x2; |
51 for i = 0:npoints-1 | |
52 retval (i+1) = x1 + i * delta; | |
53 endfor | |
54 else | 51 else |
55 error ("linspace: arguments must be scalars"); | 52 error ("linspace: arguments must be scalars"); |
56 endif | 53 endif |
57 | 54 |
58 endfunction | 55 endfunction |