annotate scripts/general/logspace.m @ 2485:eac91893f3fc

[project @ 1996-11-08 03:14:36 by jwe]
author jwe
date Fri, 08 Nov 1996 03:15:40 +0000
parents b5568c31ee2c
children 8b262e771614
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
1 ## Copyright (C) 1996 John W. Eaton
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
2 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
3 ## This file is part of Octave.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
4 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
6 ## under the terms of the GNU General Public License as published by
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
7 ## the Free Software Foundation; either version 2, or (at your option)
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
8 ## any later version.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
9 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
13 ## General Public License for more details.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
14 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
15 ## You should have received a copy of the GNU General Public License
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
16 ## along with Octave; see the file COPYING. If not, write to the Free
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
17 ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
18 ## 02111-1307, USA.
245
16a24e76d6e0 [project @ 1993-12-03 02:00:15 by jwe]
jwe
parents: 4
diff changeset
19
2311
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
20 ## usage: logspace (x1, x2, n)
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
21 ##
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
22 ## Return a vector of n logarithmically equally spaced points between
2485
eac91893f3fc [project @ 1996-11-08 03:14:36 by jwe]
jwe
parents: 2325
diff changeset
23 ## 10^x1 and 10^x2 inclusive.
2311
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
24 ##
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
25 ## If the final argument is omitted, n = 50 is assumed.
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
26 ##
2325
b5568c31ee2c [project @ 1996-07-15 22:20:21 by jwe]
jwe
parents: 2314
diff changeset
27 ## All three arguments must be scalars.
2311
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
28 ##
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
29 ## Note that if if x2 is pi, the points are between 10^x1 and pi, NOT
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
30 ## 10^x1 and 10^pi.
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
31 ##
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
32 ## Yes, this is pretty stupid, because you could achieve the same
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
33 ## result with logspace (x1, log10 (pi)), but Matlab does this, and
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
34 ## claims that is useful for signal processing applications.
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
35 ##
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
36 ## See also: linspace
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
37
2314
949ab8eba8bc [project @ 1996-07-12 03:58:02 by jwe]
jwe
parents: 2313
diff changeset
38 ## Author: jwe
949ab8eba8bc [project @ 1996-07-12 03:58:02 by jwe]
jwe
parents: 2313
diff changeset
39
2311
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
40 function retval = logspace (x1, x2, n)
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
41
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
42 if (nargin == 2)
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
43 npoints = 50;
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
44 elseif (nargin == 3)
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
45 if (length (n) == 1)
894
c215a8d174a2 [project @ 1994-11-08 21:44:41 by jwe]
jwe
parents: 415
diff changeset
46 npoints = fix (n);
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
47 else
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
48 error ("logspace: arguments must be scalars");
2325
b5568c31ee2c [project @ 1996-07-15 22:20:21 by jwe]
jwe
parents: 2314
diff changeset
49 endif
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
50 else
904
3470f1e25a79 [project @ 1994-11-09 21:22:15 by jwe]
jwe
parents: 894
diff changeset
51 usage ("logspace (x1, x2 [, n])");
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
52 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
53
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
54 if (npoints < 2)
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
55 error ("logspace: npoints must be greater than 2");
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
56 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
57
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
58 if (length (x1) == 1 && length (x2) == 1)
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
59 x2_tmp = x2;
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
60 if (x2 == pi)
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
61 x2_tmp = log10 (pi);
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
62 endif
415
0ce34c2fc3d5 [project @ 1994-05-16 18:30:52 by jwe]
jwe
parents: 245
diff changeset
63 retval = 10 .^ (linspace (x1, x2_tmp, npoints));
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
64 else
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
65 error ("logspace: arguments must be scalars");
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
66 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
67
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
68 endfunction