Mercurial > hg > octave-nkf
annotate scripts/plot/__plr2__.m @ 9249:470af0f93ca9
ghostscript handling for windows in print.m
author | Benjamin Lindner <lindnerb@users.sourceforge.net> |
---|---|
date | Sun, 24 May 2009 10:09:19 +0200 |
parents | eb63fbe60fab |
children |
rev | line source |
---|---|
7017 | 1 ## Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000, 2002, 2005, 2006, |
8920 | 2 ## 2007, 2009 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 |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8664
diff
changeset
|
20 ## -*- texinfo -*- |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8664
diff
changeset
|
21 ## @deftypefn {Function File} {} __plr2__ (@var{h}, @var{theta}, @var{rho}, @var{fmt}) |
6895 | 22 ## Undocumented internal function. |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8664
diff
changeset
|
23 ## @end deftypefn |
3402 | 24 |
2314 | 25 ## Author: jwe |
26 | |
6302 | 27 function retval = __plr2__ (h, theta, rho, fmt) |
933 | 28 |
6257 | 29 if (nargin != 4) |
6046 | 30 print_usage (); |
933 | 31 endif |
32 | |
33 if (any (imag (theta))) | |
34 theta = real (theta); | |
35 endif | |
36 | |
37 if (any (imag (rho))) | |
38 rho = real (rho); | |
39 endif | |
40 | |
4030 | 41 if (isscalar (theta)) |
42 if (isscalar (rho)) | |
933 | 43 x = rho * cos (theta); |
44 y = rho * sin (theta); | |
6302 | 45 retval = __plt__ ("polar", h, x, y, fmt); |
5115 | 46 else |
47 error ("__plr2__: invalid data for plotting"); | |
933 | 48 endif |
4030 | 49 elseif (isvector (theta)) |
50 if (isvector (rho)) | |
933 | 51 if (length (theta) != length (rho)) |
5115 | 52 error ("__plr2__: vector lengths must match"); |
933 | 53 endif |
54 if (rows (rho) == 1) | |
3426 | 55 rho = rho'; |
933 | 56 endif |
57 if (rows (theta) == 1) | |
3426 | 58 theta = theta'; |
933 | 59 endif |
60 x = rho .* cos (theta); | |
61 y = rho .* sin (theta); | |
6302 | 62 retval = __plt__ ("polar", h, x, y, fmt); |
4030 | 63 elseif (ismatrix (rho)) |
933 | 64 [t_nr, t_nc] = size (theta); |
65 if (t_nr == 1) | |
3426 | 66 theta = theta'; |
67 tmp = t_nr; | |
68 t_nr = t_nc; | |
69 t_nc = tmp; | |
933 | 70 endif |
71 [r_nr, r_nc] = size (rho); | |
72 if (t_nr != r_nr) | |
3426 | 73 rho = rho'; |
74 tmp = r_nr; | |
75 r_nr = r_nc; | |
76 r_nc = tmp; | |
933 | 77 endif |
78 if (t_nr != r_nr) | |
5115 | 79 error ("__plr2__: vector and matrix sizes must match"); |
933 | 80 endif |
81 x = diag (cos (theta)) * rho; | |
82 y = diag (sin (theta)) * rho; | |
6302 | 83 retval = __plt__ ("polar", h, x, y, fmt); |
5115 | 84 else |
8664 | 85 error ("__plr2__: invalid data for plotting"); |
933 | 86 endif |
4030 | 87 elseif (ismatrix (theta)) |
88 if (isvector (rho)) | |
933 | 89 [r_nr, r_nc] = size (rho); |
90 if (r_nr == 1) | |
3426 | 91 rho = rho'; |
92 tmp = r_nr; | |
93 r_nr = r_nc; | |
94 r_nc = tmp; | |
933 | 95 endif |
96 [t_nr, t_nc] = size (theta); | |
97 if (r_nr != t_nr) | |
3426 | 98 theta = theta'; |
99 tmp = t_nr; | |
100 t_nr = t_nc; | |
101 t_nc = tmp; | |
933 | 102 endif |
103 if (r_nr != t_nr) | |
5115 | 104 error ("__plr2__: vector and matrix sizes must match"); |
933 | 105 endif |
3238 | 106 diag_r = diag (rho); |
933 | 107 x = diag_r * cos (theta); |
108 y = diag_r * sin (theta); | |
6302 | 109 retval = __plt__ ("polar", h, x, y, fmt); |
4030 | 110 elseif (ismatrix (rho)) |
6157 | 111 if (! size_equal (rho, theta)) |
5115 | 112 error ("__plr2__: matrix dimensions must match"); |
933 | 113 endif |
114 x = rho .* cos (theta); | |
115 y = rho .* sin (theta); | |
6302 | 116 retval = __plt__ ("polar", h, x, y, fmt); |
5115 | 117 else |
8664 | 118 error ("__plr2__: invalid data for plotting"); |
933 | 119 endif |
5115 | 120 else |
8664 | 121 error ("__plr2__: invalid data for plotting"); |
933 | 122 endif |
123 | |
124 endfunction |