Mercurial > hg > octave-lyh
annotate scripts/plot/rose.m @ 10793:be55736a0783
Grammarcheck the documentation from m-files.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sun, 18 Jul 2010 20:35:16 -0700 |
parents | 95c3e38098bf |
children | a0dfd7e8e3e2 |
rev | line source |
---|---|
9245 | 1 ## Copyright (C) 2007, 2008, 2009 David Bateman |
7322 | 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 3 of the License, or (at | |
8 ## your option) 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, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 | |
19 ## -*- texinfo -*- | |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
20 ## @deftypefn {Function File} {} rose (@var{th}, @var{r}) |
7322 | 21 ## @deftypefnx {Function File} {} rose (@var{h}, @dots{}) |
7710 | 22 ## @deftypefnx {Function File} {@var{h} =} rose (@dots{}) |
23 ## @deftypefnx {Function File} {[@var{r}, @var{th}] =} rose (@dots{}) | |
7322 | 24 ## |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
25 ## Plot an angular histogram. With one vector argument @var{th}, plots the |
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
26 ## histogram with 20 angular bins. If @var{th} is a matrix, then each column |
7322 | 27 ## of @var{th} produces a separate histogram. |
28 ## | |
29 ## If @var{r} is given and is a scalar, then the histogram is produced with | |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
30 ## @var{r} bins. If @var{r} is a vector, then the center of each bin are |
7322 | 31 ## defined by the values of @var{r}. |
32 ## | |
33 ## The optional return value @var{h} provides a list of handles to the | |
34 ## the parts of the vector field (body, arrow and marker). | |
35 ## | |
36 ## If two output arguments are requested, then rather than plotting the | |
37 ## histogram, the polar vectors necessary to plot the histogram are | |
38 ## returned. | |
7710 | 39 ## |
7322 | 40 ## @example |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
41 ## @group |
7322 | 42 ## [r, t] = rose ([2*randn(1e5,1), pi + 2 * randn(1e5,1)]); |
43 ## polar (r, t); | |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
44 ## @end group |
7322 | 45 ## @end example |
46 ## | |
47 ## | |
48 ## @seealso{plot, compass, polar, hist} | |
49 ## @end deftypefn | |
50 | |
51 function [thout, rout] = rose (varargin) | |
52 | |
53 [h, varargin, nargin] = __plt_get_axis_arg__ ((nargout > 1), "rose", | |
10549 | 54 varargin{:}); |
7322 | 55 |
56 if (nargin < 1) | |
57 print_usage (); | |
58 endif | |
59 | |
60 ## Force theta to [0,2*pi] range | |
61 th = varargin {1}; | |
62 th = atan2 (sin (th), cos (th)) + pi; | |
63 | |
64 if (nargin > 1) | |
65 x = varargin {2}; | |
66 if (isscalar (x)) | |
67 x = [0.5/x : 1/x : 1] * 2 * pi; | |
68 else | |
69 ## Force theta to [0,2*pi] range | |
70 x = atan2 (sin (x), cos (x)) + pi; | |
71 endif | |
72 else | |
73 x = [1/40 : 1/20 : 1] * 2 * pi; | |
74 endif | |
75 | |
76 [nn, xx] = hist (th, x); | |
77 xx = xx(:).'; | |
78 if (isvector (nn)) | |
79 nn = nn (:); | |
80 endif | |
81 x1 = xx(1:end-1) + diff (xx, 1) / 2; | |
82 x1 = [x1 ; x1; x1; x1](:); | |
83 th = [0; 0; x1; 2*pi ; 2*pi]; | |
84 r = zeros (4 * size (nn, 1), size (nn, 2)); | |
85 r(2:4:end, :) = nn; | |
86 r(3:4:end, :) = nn; | |
87 | |
88 if (nargout < 2) | |
89 oldh = gca (); | |
90 unwind_protect | |
91 axes (h); | |
92 newplot (); | |
93 hlist = polar (h, th, r); | |
94 unwind_protect_cleanup | |
95 axes (oldh); | |
96 end_unwind_protect | |
97 | |
98 if (nargout > 0) | |
99 thout = hlist; | |
100 endif | |
101 else | |
102 thout = th; | |
103 rout = r; | |
104 endif | |
105 | |
106 endfunction | |
107 | |
108 %!demo | |
109 %! rose ([2*randn(1e5,1), pi + 2 * randn(1e5,1)]) |