7017
|
1 ## Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000, 2002, 2005, 2006, |
|
2 ## 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/>. |
933
|
19 |
6895
|
20 ## Undocumented internal function. |
3402
|
21 |
2314
|
22 ## Author: jwe |
|
23 |
6302
|
24 function retval = __plr2__ (h, theta, rho, fmt) |
933
|
25 |
6257
|
26 if (nargin != 4) |
6046
|
27 print_usage (); |
933
|
28 endif |
|
29 |
|
30 if (any (imag (theta))) |
|
31 theta = real (theta); |
|
32 endif |
|
33 |
|
34 if (any (imag (rho))) |
|
35 rho = real (rho); |
|
36 endif |
|
37 |
4030
|
38 if (isscalar (theta)) |
|
39 if (isscalar (rho)) |
933
|
40 x = rho * cos (theta); |
|
41 y = rho * sin (theta); |
6302
|
42 retval = __plt__ ("polar", h, x, y, fmt); |
5115
|
43 else |
|
44 error ("__plr2__: invalid data for plotting"); |
933
|
45 endif |
4030
|
46 elseif (isvector (theta)) |
|
47 if (isvector (rho)) |
933
|
48 if (length (theta) != length (rho)) |
5115
|
49 error ("__plr2__: vector lengths must match"); |
933
|
50 endif |
|
51 if (rows (rho) == 1) |
3426
|
52 rho = rho'; |
933
|
53 endif |
|
54 if (rows (theta) == 1) |
3426
|
55 theta = theta'; |
933
|
56 endif |
|
57 x = rho .* cos (theta); |
|
58 y = rho .* sin (theta); |
6302
|
59 retval = __plt__ ("polar", h, x, y, fmt); |
4030
|
60 elseif (ismatrix (rho)) |
933
|
61 [t_nr, t_nc] = size (theta); |
|
62 if (t_nr == 1) |
3426
|
63 theta = theta'; |
|
64 tmp = t_nr; |
|
65 t_nr = t_nc; |
|
66 t_nc = tmp; |
933
|
67 endif |
|
68 [r_nr, r_nc] = size (rho); |
|
69 if (t_nr != r_nr) |
3426
|
70 rho = rho'; |
|
71 tmp = r_nr; |
|
72 r_nr = r_nc; |
|
73 r_nc = tmp; |
933
|
74 endif |
|
75 if (t_nr != r_nr) |
5115
|
76 error ("__plr2__: vector and matrix sizes must match"); |
933
|
77 endif |
|
78 x = diag (cos (theta)) * rho; |
|
79 y = diag (sin (theta)) * rho; |
6302
|
80 retval = __plt__ ("polar", h, x, y, fmt); |
5115
|
81 else |
|
82 error ("__plr2__: invalid data for plotting") |
933
|
83 endif |
4030
|
84 elseif (ismatrix (theta)) |
|
85 if (isvector (rho)) |
933
|
86 [r_nr, r_nc] = size (rho); |
|
87 if (r_nr == 1) |
3426
|
88 rho = rho'; |
|
89 tmp = r_nr; |
|
90 r_nr = r_nc; |
|
91 r_nc = tmp; |
933
|
92 endif |
|
93 [t_nr, t_nc] = size (theta); |
|
94 if (r_nr != t_nr) |
3426
|
95 theta = theta'; |
|
96 tmp = t_nr; |
|
97 t_nr = t_nc; |
|
98 t_nc = tmp; |
933
|
99 endif |
|
100 if (r_nr != t_nr) |
5115
|
101 error ("__plr2__: vector and matrix sizes must match"); |
933
|
102 endif |
3238
|
103 diag_r = diag (rho); |
933
|
104 x = diag_r * cos (theta); |
|
105 y = diag_r * sin (theta); |
6302
|
106 retval = __plt__ ("polar", h, x, y, fmt); |
4030
|
107 elseif (ismatrix (rho)) |
6157
|
108 if (! size_equal (rho, theta)) |
5115
|
109 error ("__plr2__: matrix dimensions must match"); |
933
|
110 endif |
|
111 x = rho .* cos (theta); |
|
112 y = rho .* sin (theta); |
6302
|
113 retval = __plt__ ("polar", h, x, y, fmt); |
5115
|
114 else |
|
115 error ("__plr2__: invalid data for plotting") |
933
|
116 endif |
5115
|
117 else |
|
118 error ("__plr2__: invalid data for plotting") |
933
|
119 endif |
|
120 |
|
121 endfunction |