Mercurial > hg > octave-lyh
diff scripts/plot/triplot.m @ 13747:e8564e8b0043
Restore random number state after %!demos or %!tests
* griddata3.m, onenormest.m, trimesh.m, triplot.m, trisurf.m, svds.m:
Restore random number state after %!demos or %!tests.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Tue, 25 Oct 2011 10:56:02 -0700 |
parents | dc29b64668fa |
children | 5f0bb45e615c |
line wrap: on
line diff
--- a/scripts/plot/triplot.m +++ b/scripts/plot/triplot.m @@ -22,7 +22,7 @@ ## @deftypefnx {Function File} {@var{h} =} triplot (@dots{}) ## Plot a triangular mesh in 2D@. The variable @var{tri} is the triangular ## meshing of the points @code{(@var{x}, @var{y})} which is returned from -## @code{delaunay}. If given, the @var{linespec} determines the properties +## @code{delaunay}. If given, @var{linespec} determines the properties ## to use for the lines. The output argument @var{h} is the graphic handle ## of the plot. ## @seealso{plot, trimesh, trisurf, delaunay} @@ -35,19 +35,24 @@ endif idx = tri(:, [1, 2, 3, 1]).'; - nt = size (tri, 1); + nt = rows (tri); + handle = plot ([x(idx); NaN(1, nt)](:), + [y(idx); NaN(1, nt)](:), varargin{:}); + if (nargout > 0) - h = plot ([x(idx); NaN(1, nt)](:), - [y(idx); NaN(1, nt)](:), varargin{:}); - else - plot ([x(idx); NaN(1, nt)](:), - [y(idx); NaN(1, nt)](:), varargin{:}); + h = handle; endif + endfunction + %!demo -%! rand ('state', 2) -%! x = rand (20, 1); -%! y = rand (20, 1); +%! old_state = rand ("state"); +%! restore_state = onCleanup (@() rand ("state", old_state)); +%! rand ("state", 2); +%! N = 20; +%! x = rand (N, 1); +%! y = rand (N, 1); %! tri = delaunay (x, y); %! triplot (tri, x, y); +