annotate scripts/plot/polar.m @ 14846:460a3c6d8bf1

maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists. Example: func() => func () * dynamic.txi, func.txi, oop.txi, var.txi, embedded.cc, fortdemo.cc, funcdemo.cc, paramdemo.cc, stringdemo.cc, unwinddemo.cc, Array.cc, Array.h, CColVector.cc, CDiagMatrix.h, CMatrix.cc, CNDArray.cc, CRowVector.cc, CSparse.cc, CmplxGEPBAL.cc, EIG.cc, MSparse.cc, MatrixType.cc, Sparse-op-defs.h, Sparse-perm-op-defs.h, Sparse.cc, Sparse.h, SparseCmplxCHOL.cc, SparseCmplxCHOL.h, SparseCmplxLU.cc, SparseCmplxQR.cc, SparseCmplxQR.h, SparseQR.cc, SparseQR.h, SparsedbleCHOL.cc, SparsedbleCHOL.h, SparsedbleLU.cc, SparsedbleLU.h, base-lu.cc, cmd-hist.cc, dColVector.cc, dDiagMatrix.h, dMatrix.cc, dNDArray.cc, dRowVector.cc, dSparse.cc, dbleCHOL.cc, dbleGEPBAL.cc, dim-vector.cc, eigs-base.cc, f2c-main.c, fCColVector.cc, fCDiagMatrix.h, fCMatrix.cc, fCNDArray.cc, fCRowVector.cc, fCmplxGEPBAL.cc, fColVector.cc, fDiagMatrix.h, fEIG.cc, fMatrix.cc, fNDArray.cc, fRowVector.cc, file-ops.cc, file-stat.cc, floatCHOL.cc, floatGEPBAL.cc, idx-vector.h, lo-specfun.cc, lo-sysdep.cc, mx-inlines.cc, oct-binmap.h, oct-convn.cc, oct-md5.cc, oct-mem.h, oct-rand.cc, oct-syscalls.cc, randgamma.c, randmtzig.c, sparse-base-chol.cc, sparse-base-chol.h, sparse-base-lu.cc, sparse-dmsolve.cc, tempname.c, curl.m, divergence.m, randi.m, dlmwrite.m, edit.m, getappdata.m, what.m, getarchdir.m, install.m, installed_packages.m, repackage.m, unload_packages.m, colorbar.m, figure.m, isosurface.m, legend.m, loglog.m, plot.m, plot3.m, plotyy.m, polar.m, __errplot__.m, __ghostscript__.m, __marching_cube__.m, __plt__.m, __scatter__.m, semilogx.m, semilogy.m, trimesh.m, trisurf.m, demo.m, test.m, datetick.m, __delaunayn__.cc, __dsearchn__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc, __lin_interpn__.cc, __magick_read__.cc, __pchip_deriv__.cc, balance.cc, bsxfun.cc, ccolamd.cc, cellfun.cc, chol.cc, daspk.cc, dasrt.cc, dassl.cc, dmperm.cc, eig.cc, eigs.cc, fftw.cc, filter.cc, find.cc, kron.cc, lookup.cc, lsode.cc, matrix_type.cc, md5sum.cc, mgorth.cc, qr.cc, quad.cc, rand.cc, regexp.cc, symbfact.cc, tril.cc, urlwrite.cc, op-bm-bm.cc, op-cdm-cdm.cc, op-cell.cc, op-chm.cc, op-cm-cm.cc, op-cm-scm.cc, op-cm-sm.cc, op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc, op-fcdm-fcdm.cc, op-fcm-fcm.cc, op-fdm-fdm.cc, op-fm-fm.cc, op-int.h, op-m-m.cc, op-m-scm.cc, op-m-sm.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc, op-range.cc, op-s-scm.cc, op-s-sm.cc, op-sbm-sbm.cc, op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc, op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc, op-sm-sm.cc, op-str-str.cc, op-struct.cc, bitfcns.cc, data.cc, debug.cc, dynamic-ld.cc, error.cc, gl-render.cc, graphics.cc, graphics.in.h, load-path.cc, ls-hdf5.cc, ls-mat5.cc, ls-mat5.h, ls-oct-ascii.cc, ls-oct-ascii.h, mex.cc, mk-errno-list, oct-map.cc, oct-obj.h, oct-parse.yy, octave-config.in.cc, ov-base-int.cc, ov-base-mat.cc, ov-base.cc, ov-bool-mat.cc, ov-bool-sparse.cc, ov-bool.cc, ov-cell.cc, ov-class.cc, ov-class.h, ov-cx-mat.cc, ov-cx-sparse.cc, ov-fcn-handle.cc, ov-flt-cx-mat.cc, ov-flt-re-mat.cc, ov-intx.h, ov-range.h, ov-re-mat.cc, ov-re-sparse.cc, ov-str-mat.cc, ov-struct.cc, ov-usr-fcn.h, ov.h, pr-output.cc, pt-id.cc, pt-id.h, pt-mat.cc, pt-select.cc, sparse.cc, symtab.cc, symtab.h, syscalls.cc, toplev.cc, txt-eng-ft.cc, variables.cc, zfstream.cc, zfstream.h, Dork.m, getStash.m, myStash.m, Gork.m, Pork.m, myStash.m, getStash.m, myStash.m, getStash.m, myStash.m, fntests.m: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
author Rik <octave@nomad.inbox5.com>
date Sun, 08 Jul 2012 11:28:50 -0700
parents 11949c9795a0
children 5d3a684236b0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 14088
diff changeset
1 ## Copyright (C) 1993-2012 John W. Eaton
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
2 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
3 ## This file is part of Octave.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
4 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
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: 2311
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
8 ## your option) any later version.
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
9 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
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: 2311
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
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: 2311
diff changeset
13 ## General Public License for more details.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
14 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
17 ## <http://www.gnu.org/licenses/>.
245
16a24e76d6e0 [project @ 1993-12-03 02:00:15 by jwe]
jwe
parents: 4
diff changeset
18
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3063
diff changeset
19 ## -*- texinfo -*-
10730
390d93e20531 Plot commands now print usage information without errors
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
20 ## @deftypefn {Function File} {} polar (@var{theta}, @var{rho})
390d93e20531 Plot commands now print usage information without errors
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
21 ## @deftypefnx {Function File} {} polar (@var{theta}, @var{rho}, @var{fmt})
390d93e20531 Plot commands now print usage information without errors
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
22 ## @deftypefnx {Function File} {} polar (@var{h}, @dots{})
390d93e20531 Plot commands now print usage information without errors
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
23 ## @deftypefnx {Function File} {@var{h} =} polar (@dots{})
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 12789
diff changeset
24 ## Create a two-dimensional plot from polar coordinates @var{theta} and
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3063
diff changeset
25 ## @var{rho}.
2311
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
26 ##
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 12789
diff changeset
27 ## The optional argument @var{fmt} specifies the line format.
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 12789
diff changeset
28 ##
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 12789
diff changeset
29 ## The optional return value @var{h} is a graphics handle to the created plot.
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 12789
diff changeset
30 ##
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6448
diff changeset
31 ## @seealso{plot}
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3063
diff changeset
32 ## @end deftypefn
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
33
2314
949ab8eba8bc [project @ 1996-07-12 03:58:02 by jwe]
jwe
parents: 2313
diff changeset
34 ## Author: jwe
949ab8eba8bc [project @ 1996-07-12 03:58:02 by jwe]
jwe
parents: 2313
diff changeset
35
6302
a5cd8b77e892 [project @ 2007-02-13 08:08:33 by jwe]
jwe
parents: 6257
diff changeset
36 function retval = polar (varargin)
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
37
7321
359f464342b3 [project @ 2007-12-18 03:48:03 by jwe]
jwe
parents: 7216
diff changeset
38 [h, varargin, nargs] = __plt_get_axis_arg__ ("polar", varargin{:});
7216
5389a52df87b [project @ 2007-11-29 19:07:29 by jwe]
jwe
parents: 7215
diff changeset
39
10730
390d93e20531 Plot commands now print usage information without errors
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
40 if (nargs < 1)
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
41 print_usage ();
10730
390d93e20531 Plot commands now print usage information without errors
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
42 endif
390d93e20531 Plot commands now print usage information without errors
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
43
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
44 oldh = gca ();
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
45 unwind_protect
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
46 axes (h);
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
47 newplot ();
3063
4287b8c06fbf [project @ 1997-06-26 02:36:05 by jwe]
jwe
parents: 2847
diff changeset
48
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
49 if (nargs == 3)
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
50 if (! ischar (varargin{3}))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10226
diff changeset
51 error ("polar: third argument must be a string");
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
52 endif
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
53 tmp = __plr2__ (h, varargin{:});
7321
359f464342b3 [project @ 2007-12-18 03:48:03 by jwe]
jwe
parents: 7216
diff changeset
54 maxr = max (varargin {2} (:));
359f464342b3 [project @ 2007-12-18 03:48:03 by jwe]
jwe
parents: 7216
diff changeset
55 elseif (nargs == 2)
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
56 if (ischar (varargin{2}))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10226
diff changeset
57 tmp = __plr1__ (h, varargin{:});
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10226
diff changeset
58 if (iscomplex(varargin{1}))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10226
diff changeset
59 maxr = max (imag(varargin{1})(:));
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10226
diff changeset
60 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10226
diff changeset
61 maxr = max (varargin{1}(:));
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10226
diff changeset
62 endif
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
63 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10226
diff changeset
64 fmt = "";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10226
diff changeset
65 tmp = __plr2__ (h, varargin{:}, fmt);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10226
diff changeset
66 maxr = max (varargin {2} (:));
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
67 endif
7321
359f464342b3 [project @ 2007-12-18 03:48:03 by jwe]
jwe
parents: 7216
diff changeset
68 elseif (nargs == 1)
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
69 fmt = "";
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
70 tmp = __plr1__ (h, varargin{:}, fmt);
7321
359f464342b3 [project @ 2007-12-18 03:48:03 by jwe]
jwe
parents: 7216
diff changeset
71 if (iscomplex(varargin{1}))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10226
diff changeset
72 maxr = max (imag(varargin{1})(:));
7321
359f464342b3 [project @ 2007-12-18 03:48:03 by jwe]
jwe
parents: 7216
diff changeset
73 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10226
diff changeset
74 maxr = max (varargin{1}(:));
7321
359f464342b3 [project @ 2007-12-18 03:48:03 by jwe]
jwe
parents: 7216
diff changeset
75 endif
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
76 else
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
77 print_usage ();
934
be867ddbe4aa [project @ 1994-11-17 04:23:41 by jwe]
jwe
parents: 904
diff changeset
78 endif
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
79
7321
359f464342b3 [project @ 2007-12-18 03:48:03 by jwe]
jwe
parents: 7216
diff changeset
80 set (h, "xlim", [-maxr, maxr], "ylim", [-maxr, maxr],
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10226
diff changeset
81 "xaxislocation", "zero", "yaxislocation", "zero",
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
82 "plotboxaspectratio", [1, 1, 1]);
7321
359f464342b3 [project @ 2007-12-18 03:48:03 by jwe]
jwe
parents: 7216
diff changeset
83
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
84 if (nargout > 0)
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
85 retval = tmp;
934
be867ddbe4aa [project @ 1994-11-17 04:23:41 by jwe]
jwe
parents: 904
diff changeset
86 endif
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
87 unwind_protect_cleanup
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
88 axes (oldh);
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
89 end_unwind_protect
6302
a5cd8b77e892 [project @ 2007-02-13 08:08:33 by jwe]
jwe
parents: 6257
diff changeset
90
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
91 endfunction
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
92
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
93 function retval = __plr1__ (h, theta, fmt)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
94
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
95 if (nargin != 3)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
96 print_usage ();
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
97 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
98
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
99 [nr, nc] = size (theta);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
100 if (nr == 1)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
101 theta = theta';
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
102 tmp = nr;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
103 nr = nc;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
104 nc = tmp;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
105 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
106 theta_i = imag (theta);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
107 if (any (theta_i))
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
108 rho = theta_i;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
109 theta = real (theta);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
110 else
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
111 rho = theta;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
112 theta = (1:nr)';
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
113 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
114
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
115 retval = __plr2__ (h, theta, rho, fmt);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
116
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
117 endfunction
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
118
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
119 function retval = __plr2__ (h, theta, rho, fmt)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
120
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
121 if (nargin != 4)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
122 print_usage ();
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
123 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
124
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
125 if (any (imag (theta)))
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
126 theta = real (theta);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
127 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
128
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
129 if (any (imag (rho)))
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
130 rho = real (rho);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
131 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
132
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
133 if (isscalar (theta))
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
134 if (isscalar (rho))
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
135 x = rho * cos (theta);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
136 y = rho * sin (theta);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
137 retval = __plt__ ("polar", h, x, y, fmt);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
138 else
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
139 error ("__plr2__: invalid data for plotting");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
140 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
141 elseif (isvector (theta))
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
142 if (isvector (rho))
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
143 if (length (theta) != length (rho))
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
144 error ("__plr2__: vector lengths must match");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
145 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
146 if (rows (rho) == 1)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
147 rho = rho';
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
148 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
149 if (rows (theta) == 1)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
150 theta = theta';
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
151 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
152 x = rho .* cos (theta);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
153 y = rho .* sin (theta);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
154 retval = __plt__ ("polar", h, x, y, fmt);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
155 elseif (ismatrix (rho))
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
156 [t_nr, t_nc] = size (theta);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
157 if (t_nr == 1)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
158 theta = theta';
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
159 tmp = t_nr;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
160 t_nr = t_nc;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
161 t_nc = tmp;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
162 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
163 [r_nr, r_nc] = size (rho);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
164 if (t_nr != r_nr)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
165 rho = rho';
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
166 tmp = r_nr;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
167 r_nr = r_nc;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
168 r_nc = tmp;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
169 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
170 if (t_nr != r_nr)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
171 error ("__plr2__: vector and matrix sizes must match");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
172 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
173 x = diag (cos (theta)) * rho;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
174 y = diag (sin (theta)) * rho;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
175 retval = __plt__ ("polar", h, x, y, fmt);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
176 else
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
177 error ("__plr2__: invalid data for plotting");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
178 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
179 elseif (ismatrix (theta))
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
180 if (isvector (rho))
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
181 [r_nr, r_nc] = size (rho);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
182 if (r_nr == 1)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
183 rho = rho';
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
184 tmp = r_nr;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
185 r_nr = r_nc;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
186 r_nc = tmp;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
187 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
188 [t_nr, t_nc] = size (theta);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
189 if (r_nr != t_nr)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
190 theta = theta';
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
191 tmp = t_nr;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
192 t_nr = t_nc;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
193 t_nc = tmp;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
194 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
195 if (r_nr != t_nr)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
196 error ("__plr2__: vector and matrix sizes must match");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
197 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
198 diag_r = diag (rho);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
199 x = diag_r * cos (theta);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
200 y = diag_r * sin (theta);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
201 retval = __plt__ ("polar", h, x, y, fmt);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
202 elseif (ismatrix (rho))
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
203 if (! size_equal (rho, theta))
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
204 error ("__plr2__: matrix dimensions must match");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
205 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
206 x = rho .* cos (theta);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
207 y = rho .* sin (theta);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
208 retval = __plt__ ("polar", h, x, y, fmt);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
209 else
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
210 error ("__plr2__: invalid data for plotting");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
211 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
212 else
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
213 error ("__plr2__: invalid data for plotting");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
214 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
215
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
216 endfunction
12789
482cc053281b codesprint: Add 2 demos for polar.m
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
217
482cc053281b codesprint: Add 2 demos for polar.m
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
218
482cc053281b codesprint: Add 2 demos for polar.m
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
219 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
220 %! clf;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
221 %! theta = linspace (0,2*pi,1000);
12789
482cc053281b codesprint: Add 2 demos for polar.m
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
222 %! rho = sin (7*theta);
482cc053281b codesprint: Add 2 demos for polar.m
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
223 %! polar (theta, rho);
482cc053281b codesprint: Add 2 demos for polar.m
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
224
482cc053281b codesprint: Add 2 demos for polar.m
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
225 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
226 %! clf;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
227 %! theta = linspace (0,10*pi,1000);
12789
482cc053281b codesprint: Add 2 demos for polar.m
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
228 %! rho = sin (5/4*theta);
482cc053281b codesprint: Add 2 demos for polar.m
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
229 %! polar (theta, rho);
482cc053281b codesprint: Add 2 demos for polar.m
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
230