2303
|
1 ### Copyright (C) 1996 John W. Eaton |
|
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 |
|
17 ### Software Foundation, 59 Temple Place - Suite 330, Boston, MA |
|
18 ### 02111-1307, USA. |
933
|
19 |
|
20 function polar_int_2 (theta, rho, fmt) |
|
21 |
|
22 if (nargin != 3) |
|
23 usage ("polar_int_2 (theta, rho, fmt)"); |
|
24 endif |
|
25 |
|
26 if (any (imag (theta))) |
|
27 theta = real (theta); |
|
28 endif |
|
29 |
|
30 if (any (imag (rho))) |
|
31 rho = real (rho); |
|
32 endif |
|
33 |
|
34 if (is_scalar (theta)) |
|
35 if (is_scalar (rho)) |
|
36 x = rho * cos (theta); |
|
37 y = rho * sin (theta); |
|
38 plot_2_s_s (x, y, fmt); |
|
39 endif |
|
40 elseif (is_vector (theta)) |
|
41 if (is_vector (rho)) |
|
42 if (length (theta) != length (rho)) |
|
43 error ("polar: vector lengths must match"); |
|
44 endif |
|
45 if (rows (rho) == 1) |
|
46 rho = rho'; |
|
47 endif |
|
48 if (rows (theta) == 1) |
|
49 theta = theta'; |
|
50 endif |
|
51 x = rho .* cos (theta); |
|
52 y = rho .* sin (theta); |
|
53 plot_2_v_v (x, y, fmt); |
|
54 elseif (is_matrix (rho)) |
|
55 [t_nr, t_nc] = size (theta); |
|
56 if (t_nr == 1) |
|
57 theta = theta'; |
|
58 tmp = t_nr; |
|
59 t_nr = t_nc; |
|
60 t_nc = tmp; |
|
61 endif |
|
62 [r_nr, r_nc] = size (rho); |
|
63 if (t_nr != r_nr) |
1303
|
64 rho = rho'; |
933
|
65 tmp = r_nr; |
|
66 r_nr = r_nc; |
|
67 r_nc = tmp; |
|
68 endif |
|
69 if (t_nr != r_nr) |
|
70 error ("polar: vector and matrix sizes must match"); |
|
71 endif |
|
72 x = diag (cos (theta)) * rho; |
|
73 y = diag (sin (theta)) * rho; |
|
74 plot_2_v_m (x, y, fmt); |
|
75 endif |
|
76 elseif (is_matrix (theta)) |
|
77 if (is_vector (rho)) |
|
78 [r_nr, r_nc] = size (rho); |
|
79 if (r_nr == 1) |
|
80 rho = rho'; |
|
81 tmp = r_nr; |
|
82 r_nr = r_nc; |
|
83 r_nc = tmp; |
|
84 endif |
|
85 [t_nr, t_nc] = size (theta); |
|
86 if (r_nr != t_nr) |
1303
|
87 theta = theta'; |
933
|
88 tmp = t_nr; |
|
89 t_nr = t_nc; |
|
90 t_nc = tmp; |
|
91 endif |
|
92 if (r_nr != t_nr) |
|
93 error ("polar: vector and matrix sizes must match"); |
|
94 endif |
|
95 diag_r = diag (r); |
|
96 x = diag_r * cos (theta); |
|
97 y = diag_r * sin (theta); |
|
98 plot_2_m_v (x, y, fmt); |
|
99 elseif (is_matrix (rho)) |
|
100 if (size (rho) != size (theta)) |
|
101 error ("polar: matrix dimensions must match"); |
|
102 endif |
|
103 x = rho .* cos (theta); |
|
104 y = rho .* sin (theta); |
|
105 plot_2_m_m (x, y, fmt); |
|
106 endif |
|
107 endif |
|
108 |
|
109 endfunction |