7017
|
1 ## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2004, 2005, |
|
2 ## 2006, 2007 John W. Eaton |
2313
|
3 ## |
|
4 ## This file is part of Octave. |
|
5 ## |
|
6 ## Octave is free software; you can redistribute it and/or modify it |
|
7 ## under the terms of the GNU General Public License as published by |
7016
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
|
9 ## your option) any later version. |
2313
|
10 ## |
|
11 ## Octave is distributed in the hope that it will be useful, but |
|
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 ## General Public License for more details. |
|
15 ## |
|
16 ## You should have received a copy of the GNU General Public License |
7016
|
17 ## along with Octave; see the file COPYING. If not, see |
|
18 ## <http://www.gnu.org/licenses/>. |
245
|
19 |
3369
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} logspace (@var{base}, @var{limit}, @var{n}) |
|
22 ## Similar to @code{linspace} except that the values are logarithmically |
|
23 ## spaced from |
|
24 ## @iftex |
|
25 ## @tex |
|
26 ## $10^{base}$ to $10^{limit}$. |
|
27 ## @end tex |
|
28 ## @end iftex |
|
29 ## @ifinfo |
|
30 ## 10^base to 10^limit. |
|
31 ## @end ifinfo |
3426
|
32 ## |
3369
|
33 ## If @var{limit} is equal to |
|
34 ## @iftex |
|
35 ## @tex |
|
36 ## $\pi$, |
|
37 ## @end tex |
|
38 ## @end iftex |
|
39 ## @ifinfo |
|
40 ## pi, |
|
41 ## @end ifinfo |
|
42 ## the points are between |
|
43 ## @iftex |
|
44 ## @tex |
|
45 ## $10^{base}$ and $\pi$, |
|
46 ## @end tex |
|
47 ## @end iftex |
|
48 ## @ifinfo |
|
49 ## 10^base and pi, |
|
50 ## @end ifinfo |
|
51 ## @emph{not} |
|
52 ## @iftex |
|
53 ## @tex |
|
54 ## $10^{base}$ and $10^{\pi}$, |
|
55 ## @end tex |
|
56 ## @end iftex |
|
57 ## @ifinfo |
|
58 ## 10^base and 10^pi, |
|
59 ## @end ifinfo |
6630
|
60 ## in order to be compatible with the corresponding @sc{Matlab} |
|
61 ## function. |
|
62 ## |
|
63 ## Also for compatibility, return the second argument if fewer than two |
|
64 ## values are requested. |
5642
|
65 ## @seealso{linspace} |
3369
|
66 ## @end deftypefn |
4
|
67 |
2314
|
68 ## Author: jwe |
|
69 |
2311
|
70 function retval = logspace (x1, x2, n) |
4
|
71 |
|
72 if (nargin == 2) |
|
73 npoints = 50; |
|
74 elseif (nargin == 3) |
|
75 if (length (n) == 1) |
894
|
76 npoints = fix (n); |
4
|
77 else |
|
78 error ("logspace: arguments must be scalars"); |
2325
|
79 endif |
4
|
80 else |
6046
|
81 print_usage (); |
4
|
82 endif |
|
83 |
|
84 if (length (x1) == 1 && length (x2) == 1) |
|
85 x2_tmp = x2; |
|
86 if (x2 == pi) |
|
87 x2_tmp = log10 (pi); |
|
88 endif |
415
|
89 retval = 10 .^ (linspace (x1, x2_tmp, npoints)); |
4
|
90 else |
|
91 error ("logspace: arguments must be scalars"); |
|
92 endif |
|
93 |
|
94 endfunction |