annotate scripts/plot/__plr__.m @ 5406:c49aec8a9080

[project @ 2005-07-08 15:25:43 by jwe]
author jwe
date Fri, 08 Jul 2005 15:25:44 +0000
parents 4c8a2e4e0717
children 34f96dd5441b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2847
8b262e771614 [project @ 1997-03-27 16:18:26 by jwe]
jwe
parents: 2315
diff changeset
1 ## Copyright (C) 1996, 1997 John W. Eaton
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2303
diff changeset
2 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2303
diff changeset
3 ## This file is part of Octave.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2303
diff changeset
4 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2303
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: 2303
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: 2303
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: 2303
diff changeset
8 ## any later version.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2303
diff changeset
9 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2303
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: 2303
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2303
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: 2303
diff changeset
13 ## General Public License for more details.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2303
diff changeset
14 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2303
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: 2303
diff changeset
16 ## along with Octave; see the file COPYING. If not, write to the Free
5307
4c8a2e4e0717 [project @ 2005-04-26 19:24:27 by jwe]
jwe
parents: 5116
diff changeset
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
4c8a2e4e0717 [project @ 2005-04-26 19:24:27 by jwe]
jwe
parents: 5116
diff changeset
18 ## 02110-1301, USA.
245
16a24e76d6e0 [project @ 1993-12-03 02:00:15 by jwe]
jwe
parents: 4
diff changeset
19
3449
858695b3ed62 [project @ 2000-01-18 04:08:59 by jwe]
jwe
parents: 3402
diff changeset
20 ## -*- texinfo -*-
858695b3ed62 [project @ 2000-01-18 04:08:59 by jwe]
jwe
parents: 3402
diff changeset
21 ## @deftypefn {Function File} {} __plr__ (@var{theta}, @var{rho}, @var{fmt})
858695b3ed62 [project @ 2000-01-18 04:08:59 by jwe]
jwe
parents: 3402
diff changeset
22 ## @end deftypefn
3402
9610d364e444 [project @ 2000-01-05 04:36:38 by jwe]
jwe
parents: 2847
diff changeset
23
2314
949ab8eba8bc [project @ 1996-07-12 03:58:02 by jwe]
jwe
parents: 2313
diff changeset
24 ## Author: jwe
949ab8eba8bc [project @ 1996-07-12 03:58:02 by jwe]
jwe
parents: 2313
diff changeset
25
2315
bf8b1bffb58f [project @ 1996-07-12 17:22:07 by jwe]
jwe
parents: 2314
diff changeset
26 function __plr__ (theta, rho, fmt)
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
27
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
28 if (nargin == 1)
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
29 [nr, nc] = size (theta);
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
30 if (nr == 1)
1518
84bd88b8acee [project @ 1995-10-04 03:35:16 by jwe]
jwe
parents: 1315
diff changeset
31 theta = theta.';
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
32 tmp = nr;
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
33 nr = nc;
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
34 nc = tmp;
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
35 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
36 theta_i = imag (theta);
934
be867ddbe4aa [project @ 1994-11-17 04:23:41 by jwe]
jwe
parents: 904
diff changeset
37 if (any (theta_i))
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
38 rho = theta_i;
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
39 theta = real (theta);
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
40 else
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
41 rho = theta;
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
42 theta = (1:nr)';
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
43 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
44 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
45
5115
57372235194b [project @ 2005-01-24 18:38:45 by jwe]
jwe
parents: 4030
diff changeset
46 ## Note that we call __plt__ instead of __pltXX__ below, even though
57372235194b [project @ 2005-01-24 18:38:45 by jwe]
jwe
parents: 4030
diff changeset
47 ## we know the argument types. This is so we don't have to duplicate
57372235194b [project @ 2005-01-24 18:38:45 by jwe]
jwe
parents: 4030
diff changeset
48 ## the functionality of __plt__ here (the __pltXX__ functions only
57372235194b [project @ 2005-01-24 18:38:45 by jwe]
jwe
parents: 4030
diff changeset
49 ## return data and fmtstr now).
57372235194b [project @ 2005-01-24 18:38:45 by jwe]
jwe
parents: 4030
diff changeset
50
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
51 if (nargin <= 2)
934
be867ddbe4aa [project @ 1994-11-17 04:23:41 by jwe]
jwe
parents: 904
diff changeset
52 if (any (imag (theta)))
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
53 theta = real (theta);
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
54 endif
934
be867ddbe4aa [project @ 1994-11-17 04:23:41 by jwe]
jwe
parents: 904
diff changeset
55 if (any (imag (rho)))
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
56 rho = real (rho);
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
57 endif
4030
22bd65326ec1 [project @ 2002-08-09 18:58:13 by jwe]
jwe
parents: 3456
diff changeset
58 if (isscalar (theta))
22bd65326ec1 [project @ 2002-08-09 18:58:13 by jwe]
jwe
parents: 3456
diff changeset
59 if (isscalar (rho))
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
60 x = rho * cos (theta);
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
61 y = rho * sin (theta);
5116
67320fb4ae5c [project @ 2005-01-25 03:57:01 by jwe]
jwe
parents: 5115
diff changeset
62 __plt__ ("polar", x, y, fmt);
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
63 endif
4030
22bd65326ec1 [project @ 2002-08-09 18:58:13 by jwe]
jwe
parents: 3456
diff changeset
64 elseif (isvector (theta))
22bd65326ec1 [project @ 2002-08-09 18:58:13 by jwe]
jwe
parents: 3456
diff changeset
65 if (isvector (rho))
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
66 if (length (theta) != length (rho))
904
3470f1e25a79 [project @ 1994-11-09 21:22:15 by jwe]
jwe
parents: 245
diff changeset
67 error ("polar: vector lengths must match");
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
68 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
69 if (rows (rho) == 1)
1518
84bd88b8acee [project @ 1995-10-04 03:35:16 by jwe]
jwe
parents: 1315
diff changeset
70 rho = rho.';
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
71 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
72 if (rows (theta) == 1)
1518
84bd88b8acee [project @ 1995-10-04 03:35:16 by jwe]
jwe
parents: 1315
diff changeset
73 theta = theta.';
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
74 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
75 x = rho .* cos (theta);
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
76 y = rho .* sin (theta);
5116
67320fb4ae5c [project @ 2005-01-25 03:57:01 by jwe]
jwe
parents: 5115
diff changeset
77 __plt__ ("polar", x, y, fmt);
4030
22bd65326ec1 [project @ 2002-08-09 18:58:13 by jwe]
jwe
parents: 3456
diff changeset
78 elseif (ismatrix (rho))
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
79 [t_nr, t_nc] = size (theta);
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
80 if (t_nr == 1)
1518
84bd88b8acee [project @ 1995-10-04 03:35:16 by jwe]
jwe
parents: 1315
diff changeset
81 theta = theta.';
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
82 tmp = t_nr;
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
83 t_nr = t_nc;
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
84 t_nc = tmp;
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
85 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
86 [r_nr, r_nc] = size (rho);
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
87 if (t_nr != r_nr)
1518
84bd88b8acee [project @ 1995-10-04 03:35:16 by jwe]
jwe
parents: 1315
diff changeset
88 rho = rho.';
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
89 tmp = r_nr;
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
90 r_nr = r_nc;
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
91 r_nc = tmp;
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
92 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
93 if (t_nr != r_nr)
904
3470f1e25a79 [project @ 1994-11-09 21:22:15 by jwe]
jwe
parents: 245
diff changeset
94 error ("polar: vector and matrix sizes must match");
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
95 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
96 x = diag (cos (theta)) * rho;
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
97 y = diag (sin (theta)) * rho;
5116
67320fb4ae5c [project @ 2005-01-25 03:57:01 by jwe]
jwe
parents: 5115
diff changeset
98 __plt__ ("polar", x, y, fmt);
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
99 endif
4030
22bd65326ec1 [project @ 2002-08-09 18:58:13 by jwe]
jwe
parents: 3456
diff changeset
100 elseif (ismatrix (theta))
22bd65326ec1 [project @ 2002-08-09 18:58:13 by jwe]
jwe
parents: 3456
diff changeset
101 if (isvector (rho))
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
102 [r_nr, r_nc] = size (rho);
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
103 if (r_nr == 1)
1518
84bd88b8acee [project @ 1995-10-04 03:35:16 by jwe]
jwe
parents: 1315
diff changeset
104 rho = rho.';
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
105 tmp = r_nr;
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
106 r_nr = r_nc;
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
107 r_nc = tmp;
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
108 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
109 [t_nr, t_nc] = size (theta);
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
110 if (r_nr != t_nr)
1518
84bd88b8acee [project @ 1995-10-04 03:35:16 by jwe]
jwe
parents: 1315
diff changeset
111 theta = rho.';
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
112 tmp = t_nr;
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
113 t_nr = t_nc;
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
114 t_nc = tmp;
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
115 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
116 if (r_nr != t_nr)
904
3470f1e25a79 [project @ 1994-11-09 21:22:15 by jwe]
jwe
parents: 245
diff changeset
117 error ("polar: vector and matrix sizes must match");
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
118 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
119 diag_r = diag (r);
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
120 x = diag_r * cos (theta);
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
121 y = diag_r * sin (theta);
5116
67320fb4ae5c [project @ 2005-01-25 03:57:01 by jwe]
jwe
parents: 5115
diff changeset
122 __plt__ ("polar", x, y, fmt);
4030
22bd65326ec1 [project @ 2002-08-09 18:58:13 by jwe]
jwe
parents: 3456
diff changeset
123 elseif (ismatrix (rho))
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
124 if (size (rho) != size (theta))
904
3470f1e25a79 [project @ 1994-11-09 21:22:15 by jwe]
jwe
parents: 245
diff changeset
125 error ("polar: matrix dimensions must match");
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
126 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
127 x = rho .* cos (theta);
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
128 y = rho .* sin (theta);
5116
67320fb4ae5c [project @ 2005-01-25 03:57:01 by jwe]
jwe
parents: 5115
diff changeset
129 __plt__ ("polar", x, y, fmt);
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
130 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
131 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
132 else
3456
434790acb067 [project @ 2000-01-19 06:58:51 by jwe]
jwe
parents: 3449
diff changeset
133 usage ("__plr__ (x, y)");
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
134 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
135
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
136 endfunction