diff scripts/plot/trisurf.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 e81ddf9cacd5
children 5f0bb45e615c
line wrap: on
line diff
--- a/scripts/plot/trisurf.m
+++ b/scripts/plot/trisurf.m
@@ -27,7 +27,7 @@
 ## @seealso{triplot, trimesh, delaunay3}
 ## @end deftypefn
 
-function varargout = trisurf (tri, x, y, z, varargin)
+function h = trisurf (tri, x, y, z, varargin)
 
   if (nargin < 3)
     print_usage ();
@@ -55,11 +55,11 @@
       varargin(end+(1:2)) = {"EdgeColor", "none"};
     endif
     newplot ();
-    h = patch ("Faces", tri, "Vertices", [x(:), y(:), z(:)],
-               "FaceVertexCData", reshape (c, numel (c), 1),
-               varargin{:});
+    handle = patch ("Faces", tri, "Vertices", [x(:), y(:), z(:)],
+                    "FaceVertexCData", reshape (c, numel (c), 1),
+                    varargin{:});
     if (nargout > 0)
-      varargout = {h};
+      h = handle;
     endif
 
     if (! ishold ())
@@ -67,11 +67,15 @@
            "xgrid", "on", "ygrid", "on", "zgrid", "on");
     endif
   endif
+
 endfunction
 
+
 %!demo
+%! old_state = rand ("state");
+%! restore_state = onCleanup (@() rand ("state", old_state));
+%! rand ("state", 10);
 %! N = 10;
-%! rand ('state', 10)
 %! x = 3 - 6 * rand (N, N);
 %! y = 3 - 6 * rand (N, N);
 %! z = peaks (x, y);
@@ -99,4 +103,3 @@
 %! tri = delaunay (x, y);
 %! trisurf (tri, x, y, z, "facecolor", "interp", "edgecolor", "k")
 
-