Mercurial > hg > octave-lyh
annotate scripts/plot/comet.m @ 11341:3c7ba1e3dc21
Add missing option slice for pie and pie3
author | Kai Habel <kai.habel@gmx.de> |
---|---|
date | Fri, 10 Dec 2010 19:53:06 +0100 |
parents | 2c356a35d7f5 |
children | a0278a856516 |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 2008, 2009 Ben Abbott |
8126 | 2 ## |
11104 | 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 ## | |
8126 | 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} {} comet (@var{y}) |
8126 | 21 ## @deftypefnx {Function File} {} comet (@var{x}, @var{y}) |
22 ## @deftypefnx {Function File} {} comet (@var{x}, @var{y}, @var{p}) | |
23 ## @deftypefnx {Function File} {} comet (@var{ax}, @dots{}) | |
24 ## Produce a simple comet style animation along the trajectory provided by | |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
25 ## the input coordinate vectors (@var{x}, @var{y}), where @var{x} will default |
8126 | 26 ## to the indices of @var{y}. |
27 ## | |
28 ## The speed of the comet may be controlled by @var{p}, which represents the | |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
29 ## time which passes as the animation passes from one point to the next. The |
8126 | 30 ## default for @var{p} is 0.1 seconds. |
31 ## | |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
32 ## If @var{ax} is specified the animation is produced in that axis rather than |
8126 | 33 ## the @code{gca}. |
34 ## @end deftypefn | |
35 | |
36 ## Author: Ben Abbott bpabbott@mac.com | |
37 ## Created: 2008-09-21 | |
38 | |
39 function comet (varargin) | |
40 | |
41 if (nargin == 0) | |
42 print_usage (); | |
8240
5cfeb7bc497a
comet.m,hold.m: validate axes handle
Ben Abbott <bpabbott@mac.com>
parents:
8236
diff
changeset
|
43 elseif (numel (varargin{1}) == 1 && ishandle (varargin{1}) |
10549 | 44 && strcmpi (get (varargin{1}, "type"), "axes")) |
8126 | 45 axes (varargin{1}); |
46 varargin = varargin(2:end); | |
47 numargin = nargin - 1; | |
48 else | |
49 numargin = nargin; | |
50 endif | |
51 | |
52 p = 0.1; | |
53 if (numargin == 1) | |
54 y = varargin{1}; | |
55 x = 1:numel(y); | |
56 elseif (numargin == 2) | |
57 x = varargin{1}; | |
58 y = varargin{2}; | |
59 elseif (numargin == 3) | |
60 x = varargin{1}; | |
61 y = varargin{2}; | |
62 p = varargin{3}; | |
63 else | |
64 print_usage (); | |
65 endif | |
66 | |
67 theaxis = [min(x), max(x), min(y), max(y)]; | |
68 num = numel (y); | |
69 dn = round (num/10); | |
70 for n = 1:(num+dn); | |
71 m = n - dn; | |
72 m = max ([m, 1]); | |
73 k = min ([n, num]); | |
74 h = plot (x(1:m), y(1:m), "r", x(m:k), y(m:k), "g", x(k), y(k), "ob"); | |
75 axis (theaxis); | |
76 drawnow (); | |
77 pause (p); | |
78 endfor | |
79 | |
80 endfunction | |
81 | |
82 %!demo | |
8790
a013ff655ca4
Trivial changes to demos to produce a more pleasant output for octave+gnuplot+aquaterm.
Ben Abbott <bpabbott@mac.com>
parents:
8240
diff
changeset
|
83 %! clf |
8126 | 84 %! t = 0:.1:2*pi; |
85 %! x = cos(2*t).*(cos(t).^2); | |
86 %! y = sin(2*t).*(sin(t).^2); | |
87 %! comet(x,y) | |
88 | |
89 |