Mercurial > hg > octave-lyh
annotate scripts/plot/cylinder.m @ 16580:adc150db1809
style fixes for uigetfile changes
* dialog.cc, dialog.h, main-window.cc, octave-qt-link.cc,
octave-qt-link.h, octave-link.cc, octave-link.h, uigetfile.m:
Style fixes.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 28 Apr 2013 13:41:37 -0400 |
parents | 5d3a684236b0 |
children | 3e1b24a2454a |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14092
diff
changeset
|
1 ## Copyright (C) 2007-2012 Michael Goffioul and Kai Habel |
7181 | 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} {} cylinder |
7181 | 21 ## @deftypefnx {Function File} {} cylinder (@var{r}) |
22 ## @deftypefnx {Function File} {} cylinder (@var{r}, @var{n}) | |
23 ## @deftypefnx {Function File} {[@var{x}, @var{y}, @var{z}] =} cylinder (@dots{}) | |
24 ## @deftypefnx {Function File} {} cylinder (@var{ax}, @dots{}) | |
12575
d0b799dafede
Grammarcheck files for 3.4.1 release.
Rik <octave@nomad.inbox5.com>
parents:
12129
diff
changeset
|
25 ## Generate three matrices in @code{meshgrid} format, such that |
7181 | 26 ## @code{surf (@var{x}, @var{y}, @var{z})} generates a unit cylinder. |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
27 ## The matrices are of size @code{@var{n}+1}-by-@code{@var{n}+1}. |
7181 | 28 ## @var{r} is a vector containing the radius along the z-axis. |
29 ## If @var{n} or @var{r} are omitted then default values of 20 or [1 1] | |
30 ## are assumed. | |
31 ## | |
32 ## Called with no return arguments, @code{cylinder} calls directly | |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
7245
diff
changeset
|
33 ## @code{surf (@var{x}, @var{y}, @var{z})}. If an axes handle @var{ax} |
7182 | 34 ## is passed as the first argument, the surface is plotted to this set |
35 ## of axes. | |
7181 | 36 ## |
37 ## Examples: | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
38 ## |
7181 | 39 ## @example |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
40 ## @group |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
41 ## [x, y, z] = cylinder (10:-1:0, 50); |
7182 | 42 ## surf (x, y, z); |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
43 ## title ("a cone"); |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
44 ## @end group |
7181 | 45 ## @end example |
46 ## @seealso{sphere} | |
47 ## @end deftypefn | |
48 | |
7182 | 49 function [xx, yy, zz] = cylinder (varargin) |
7181 | 50 |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
51 [ax, args, nargs] = __plt_get_axis_arg__ ((nargout > 0), "cylinder", |
10549 | 52 varargin{:}); |
7181 | 53 |
54 if (nargs == 0) | |
55 n = 20; | |
7182 | 56 r = [1, 1]; |
7181 | 57 elseif (nargs == 1) |
58 n = 20; | |
59 r = args{1}; | |
60 elseif (nargs == 2) | |
61 r = args{1}; | |
62 n = args{2}; | |
63 else | |
7182 | 64 print_usage (); |
7181 | 65 endif |
66 | |
7182 | 67 if (length (r) < 2) |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14335
diff
changeset
|
68 error ("cylinder: length (R) must be larger than 2"); |
7181 | 69 endif |
70 | |
7182 | 71 phi = linspace (0, 2*pi, n+1); |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14335
diff
changeset
|
72 idx = 1:length (r); |
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14335
diff
changeset
|
73 [phi, idx] = meshgrid (phi, idx); |
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14335
diff
changeset
|
74 z = (idx - 1) / (length (r) - 1); |
7181 | 75 r = r(idx); |
7182 | 76 [x, y] = pol2cart (phi, r); |
7181 | 77 |
78 if (nargout > 0) | |
79 xx = x; | |
80 yy = y; | |
81 zz = z; | |
82 else | |
7215 | 83 surf (ax, x, y, z); |
7181 | 84 endif |
85 | |
86 endfunction | |
7245 | 87 |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
88 |
7245 | 89 %!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
|
90 %! clf; |
14247
c4fa5e0b6193
test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents:
14245
diff
changeset
|
91 %! colormap ('default'); |
7245 | 92 %! [x, y, z] = cylinder (10:-1:0,50); |
93 %! surf (x, y, z); | |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
94 %! title ('a cone'); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
95 |