2847
|
1 ## Copyright (C) 1996, 1997 John W. Eaton |
2313
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
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 |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
933
|
19 |
3449
|
20 ## -*- texinfo -*- |
6257
|
21 ## @deftypefn {Function File} {} __plr2__ (@var{h}, @var{theta}, @var{rho}, @var{fmt}) |
3449
|
22 ## @end deftypefn |
3402
|
23 |
2314
|
24 ## Author: jwe |
|
25 |
6302
|
26 function retval = __plr2__ (h, theta, rho, fmt) |
933
|
27 |
6257
|
28 if (nargin != 4) |
6046
|
29 print_usage (); |
933
|
30 endif |
|
31 |
|
32 if (any (imag (theta))) |
|
33 theta = real (theta); |
|
34 endif |
|
35 |
|
36 if (any (imag (rho))) |
|
37 rho = real (rho); |
|
38 endif |
|
39 |
4030
|
40 if (isscalar (theta)) |
|
41 if (isscalar (rho)) |
933
|
42 x = rho * cos (theta); |
|
43 y = rho * sin (theta); |
6302
|
44 retval = __plt__ ("polar", h, x, y, fmt); |
5115
|
45 else |
|
46 error ("__plr2__: invalid data for plotting"); |
933
|
47 endif |
4030
|
48 elseif (isvector (theta)) |
|
49 if (isvector (rho)) |
933
|
50 if (length (theta) != length (rho)) |
5115
|
51 error ("__plr2__: vector lengths must match"); |
933
|
52 endif |
|
53 if (rows (rho) == 1) |
3426
|
54 rho = rho'; |
933
|
55 endif |
|
56 if (rows (theta) == 1) |
3426
|
57 theta = theta'; |
933
|
58 endif |
|
59 x = rho .* cos (theta); |
|
60 y = rho .* sin (theta); |
6302
|
61 retval = __plt__ ("polar", h, x, y, fmt); |
4030
|
62 elseif (ismatrix (rho)) |
933
|
63 [t_nr, t_nc] = size (theta); |
|
64 if (t_nr == 1) |
3426
|
65 theta = theta'; |
|
66 tmp = t_nr; |
|
67 t_nr = t_nc; |
|
68 t_nc = tmp; |
933
|
69 endif |
|
70 [r_nr, r_nc] = size (rho); |
|
71 if (t_nr != r_nr) |
3426
|
72 rho = rho'; |
|
73 tmp = r_nr; |
|
74 r_nr = r_nc; |
|
75 r_nc = tmp; |
933
|
76 endif |
|
77 if (t_nr != r_nr) |
5115
|
78 error ("__plr2__: vector and matrix sizes must match"); |
933
|
79 endif |
|
80 x = diag (cos (theta)) * rho; |
|
81 y = diag (sin (theta)) * rho; |
6302
|
82 retval = __plt__ ("polar", h, x, y, fmt); |
5115
|
83 else |
|
84 error ("__plr2__: invalid data for plotting") |
933
|
85 endif |
4030
|
86 elseif (ismatrix (theta)) |
|
87 if (isvector (rho)) |
933
|
88 [r_nr, r_nc] = size (rho); |
|
89 if (r_nr == 1) |
3426
|
90 rho = rho'; |
|
91 tmp = r_nr; |
|
92 r_nr = r_nc; |
|
93 r_nc = tmp; |
933
|
94 endif |
|
95 [t_nr, t_nc] = size (theta); |
|
96 if (r_nr != t_nr) |
3426
|
97 theta = theta'; |
|
98 tmp = t_nr; |
|
99 t_nr = t_nc; |
|
100 t_nc = tmp; |
933
|
101 endif |
|
102 if (r_nr != t_nr) |
5115
|
103 error ("__plr2__: vector and matrix sizes must match"); |
933
|
104 endif |
3238
|
105 diag_r = diag (rho); |
933
|
106 x = diag_r * cos (theta); |
|
107 y = diag_r * sin (theta); |
6302
|
108 retval = __plt__ ("polar", h, x, y, fmt); |
4030
|
109 elseif (ismatrix (rho)) |
6157
|
110 if (! size_equal (rho, theta)) |
5115
|
111 error ("__plr2__: matrix dimensions must match"); |
933
|
112 endif |
|
113 x = rho .* cos (theta); |
|
114 y = rho .* sin (theta); |
6302
|
115 retval = __plt__ ("polar", h, x, y, fmt); |
5115
|
116 else |
|
117 error ("__plr2__: invalid data for plotting") |
933
|
118 endif |
5115
|
119 else |
|
120 error ("__plr2__: invalid data for plotting") |
933
|
121 endif |
|
122 |
|
123 endfunction |