Mercurial > hg > octave-nkf
comparison scripts/plot/ezmesh.m @ 16993:78f57b14535c
Overhaul ez* family of plot functions.
* scripts/plot/ezcontour.m, scripts/plot/ezcontourf.m, scripts/plot/ezmesh.m,
scripts/plot/ezmeshc.m, scripts/plot/ezpolar.m, scripts/plot/ezsurfc.m:
Redo docstring. Match function output names to docstring.
* scripts/plot/ezplot.m: Add %!demo block with sinc function.
Redo docstring. Match function output names to docstring.
scripts/plot/ezplot3.m: Add %!demo block showing 'animate' option.
Redo docstring. Match function output names to docstring.
* scripts/plot/ezsurf.m: Add %!demo block showing 'circ' argument.
Redo docstring. Match function output names to docstring.
* scripts/plot/private/__ezplot__.m:
Implement 'circ' option for ezsurf, ezmesh.
Implement 'animate' option for ezplot3.
Implement new algorithm for finding valid axis setting for mesh, surf, contour
plots based on function gradient.
Eliminate complex Z values along with singularities because these are not
plottable by mesh, surf.
Implement Matlab-compatible 2-pass approach to finding valid domain for plot.
Use 500 points for point-style plot functions ezplot, ezplot3, ezpolar rather
than previous 60 for a smoother plot.
Use better regexprep() calls to format "pretty print" title string.
Relax input checking and allow 3rd parametric function to be a function of 1
variable only.
Clean up code and use Octave coding conventions.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 17 Jul 2013 10:09:44 -0700 |
parents | 5d3a684236b0 |
children | eaab03308c0b |
comparison
equal
deleted
inserted
replaced
16992:4e8f49304059 | 16993:78f57b14535c |
---|---|
20 ## @deftypefn {Function File} {} ezmesh (@var{f}) | 20 ## @deftypefn {Function File} {} ezmesh (@var{f}) |
21 ## @deftypefnx {Function File} {} ezmesh (@var{fx}, @var{fy}, @var{fz}) | 21 ## @deftypefnx {Function File} {} ezmesh (@var{fx}, @var{fy}, @var{fz}) |
22 ## @deftypefnx {Function File} {} ezmesh (@dots{}, @var{dom}) | 22 ## @deftypefnx {Function File} {} ezmesh (@dots{}, @var{dom}) |
23 ## @deftypefnx {Function File} {} ezmesh (@dots{}, @var{n}) | 23 ## @deftypefnx {Function File} {} ezmesh (@dots{}, @var{n}) |
24 ## @deftypefnx {Function File} {} ezmesh (@dots{}, "circ") | 24 ## @deftypefnx {Function File} {} ezmesh (@dots{}, "circ") |
25 ## @deftypefnx {Function File} {} ezmesh (@var{h}, @dots{}) | 25 ## @deftypefnx {Function File} {} ezmesh (@var{hax}, @dots{}) |
26 ## @deftypefnx {Function File} {@var{h} =} ezmesh (@dots{}) | 26 ## @deftypefnx {Function File} {@var{h} =} ezmesh (@dots{}) |
27 ## | 27 ## |
28 ## Plot the mesh defined by a function. @var{f} is a string, inline | 28 ## Plot the mesh defined by a function. |
29 ## function or function handle with two arguments defining the function. By | |
30 ## default the plot is over the domain @code{-2*pi < @var{x} < 2*pi} and | |
31 ## @code{-2*pi < @var{y} < 2*pi} with 60 points in each dimension. | |
32 ## | 29 ## |
33 ## If @var{dom} is a two element vector, it represents the minimum and maximum | 30 ## @var{f} is a string, inline function, or function handle with two arguments |
34 ## value of both @var{x} and @var{y}. If @var{dom} is a four element vector, | 31 ## defining the function. By default the plot is over the meshed domain |
35 ## then the minimum and maximum value of @var{x} and @var{y} are specify | 32 ## @code{-2*pi <= @var{x} | @var{y} <= 2*pi} with 60 points in each dimension. |
36 ## separately. | |
37 ## | |
38 ## @var{n} is a scalar defining the number of points to use in each dimension. | |
39 ## | 33 ## |
40 ## If three functions are passed, then plot the parametrically defined | 34 ## If three functions are passed, then plot the parametrically defined |
41 ## function @code{[@var{fx} (@var{s}, @var{t}), @var{fy} (@var{s}, @var{t}), | 35 ## function @code{[@var{fx} (@var{s}, @var{t}), @var{fy} (@var{s}, @var{t}), |
42 ## @var{fz} (@var{s}, @var{t})]}. | 36 ## @var{fz} (@var{s}, @var{t})]}. |
43 ## | 37 ## |
38 ## If @var{dom} is a two element vector, it represents the minimum and maximum | |
39 ## values of both @var{x} and @var{y}. If @var{dom} is a four element vector, | |
40 ## then the minimum and maximum values are @code{[xmin xmax ymin ymax]}. | |
41 ## | |
42 ## @var{n} is a scalar defining the number of points to use in each dimension. | |
43 ## | |
44 ## If the argument "circ" is given, then the function is plotted over a disk | 44 ## If the argument "circ" is given, then the function is plotted over a disk |
45 ## centered on the middle of the domain @var{dom}. | 45 ## centered on the middle of the domain @var{dom}. |
46 ## | 46 ## |
47 ## If the first argument is an axis handle, @var{hax}, then plot into this | |
48 ## axis rather than the current axis handle returned by @code{gca}. | |
49 ## | |
47 ## The optional return value @var{h} is a graphics handle to the created | 50 ## The optional return value @var{h} is a graphics handle to the created |
48 ## surface object. | 51 ## surface object. |
52 ## | |
53 ## Example 1: 2-argument function | |
49 ## | 54 ## |
50 ## @example | 55 ## @example |
51 ## @group | 56 ## @group |
52 ## f = @@(x,y) sqrt (abs (x .* y)) ./ (1 + x.^2 + y.^2); | 57 ## f = @@(x,y) sqrt (abs (x .* y)) ./ (1 + x.^2 + y.^2); |
53 ## ezmesh (f, [-3, 3]); | 58 ## ezmesh (f, [-3, 3]); |
54 ## @end group | 59 ## @end group |
55 ## @end example | 60 ## @end example |
56 ## | 61 ## |
57 ## An example of a parametrically defined function is | 62 ## Example 2: parametrically defined function |
58 ## | 63 ## |
59 ## @example | 64 ## @example |
60 ## @group | 65 ## @group |
61 ## fx = @@(s,t) cos (s) .* cos (t); | 66 ## fx = @@(s,t) cos (s) .* cos (t); |
62 ## fy = @@(s,t) sin (s) .* cos (t); | 67 ## fy = @@(s,t) sin (s) .* cos (t); |
63 ## fz = @@(s,t) sin (t); | 68 ## fz = @@(s,t) sin (t); |
64 ## ezmesh (fx, fy, fz, [-pi, pi, -pi/2, pi/2], 20); | 69 ## ezmesh (fx, fy, fz, [-pi, pi, -pi/2, pi/2], 20); |
65 ## @end group | 70 ## @end group |
66 ## @end example | 71 ## @end example |
67 ## | 72 ## |
68 ## @seealso{ezplot, ezmeshc, ezsurf, ezsurfc} | 73 ## @seealso{mesh, ezmeshc, ezplot, ezsurf, ezsurfc, hidden} |
69 ## @end deftypefn | 74 ## @end deftypefn |
70 | 75 |
71 function retval = ezmesh (varargin) | 76 function h = ezmesh (varargin) |
72 | 77 |
73 [h, needusage] = __ezplot__ ("mesh", varargin{:}); | 78 [htmp, needusage] = __ezplot__ ("mesh", varargin{:}); |
74 | 79 |
75 if (needusage) | 80 if (needusage) |
76 print_usage (); | 81 print_usage (); |
77 endif | 82 endif |
78 | 83 |
79 if (nargout > 0) | 84 if (nargout > 0) |
80 retval = h; | 85 h = htmp; |
81 endif | 86 endif |
82 | 87 |
83 endfunction | 88 endfunction |
84 | 89 |
85 | 90 |