comparison 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
comparison
equal deleted inserted replaced
13746:7ff0bdc3dc4c 13747:e8564e8b0043
20 ## @deftypefn {Function File} {} triplot (@var{tri}, @var{x}, @var{y}) 20 ## @deftypefn {Function File} {} triplot (@var{tri}, @var{x}, @var{y})
21 ## @deftypefnx {Function File} {} triplot (@var{tri}, @var{x}, @var{y}, @var{linespec}) 21 ## @deftypefnx {Function File} {} triplot (@var{tri}, @var{x}, @var{y}, @var{linespec})
22 ## @deftypefnx {Function File} {@var{h} =} triplot (@dots{}) 22 ## @deftypefnx {Function File} {@var{h} =} triplot (@dots{})
23 ## Plot a triangular mesh in 2D@. The variable @var{tri} is the triangular 23 ## Plot a triangular mesh in 2D@. The variable @var{tri} is the triangular
24 ## meshing of the points @code{(@var{x}, @var{y})} which is returned from 24 ## meshing of the points @code{(@var{x}, @var{y})} which is returned from
25 ## @code{delaunay}. If given, the @var{linespec} determines the properties 25 ## @code{delaunay}. If given, @var{linespec} determines the properties
26 ## to use for the lines. The output argument @var{h} is the graphic handle 26 ## to use for the lines. The output argument @var{h} is the graphic handle
27 ## of the plot. 27 ## of the plot.
28 ## @seealso{plot, trimesh, trisurf, delaunay} 28 ## @seealso{plot, trimesh, trisurf, delaunay}
29 ## @end deftypefn 29 ## @end deftypefn
30 30
33 if (nargin < 3) 33 if (nargin < 3)
34 print_usage (); 34 print_usage ();
35 endif 35 endif
36 36
37 idx = tri(:, [1, 2, 3, 1]).'; 37 idx = tri(:, [1, 2, 3, 1]).';
38 nt = size (tri, 1); 38 nt = rows (tri);
39 handle = plot ([x(idx); NaN(1, nt)](:),
40 [y(idx); NaN(1, nt)](:), varargin{:});
41
39 if (nargout > 0) 42 if (nargout > 0)
40 h = plot ([x(idx); NaN(1, nt)](:), 43 h = handle;
41 [y(idx); NaN(1, nt)](:), varargin{:});
42 else
43 plot ([x(idx); NaN(1, nt)](:),
44 [y(idx); NaN(1, nt)](:), varargin{:});
45 endif 44 endif
45
46 endfunction 46 endfunction
47 47
48
48 %!demo 49 %!demo
49 %! rand ('state', 2) 50 %! old_state = rand ("state");
50 %! x = rand (20, 1); 51 %! restore_state = onCleanup (@() rand ("state", old_state));
51 %! y = rand (20, 1); 52 %! rand ("state", 2);
53 %! N = 20;
54 %! x = rand (N, 1);
55 %! y = rand (N, 1);
52 %! tri = delaunay (x, y); 56 %! tri = delaunay (x, y);
53 %! triplot (tri, x, y); 57 %! triplot (tri, x, y);
58