# HG changeset patch # User Rik # Date 1375549507 25200 # Node ID 4b834dbe4b3ecfc6b8c2cc1762e0f504e33e606a # Parent 1e2641277b2aa715f27b583a65221365697a506b meshz.m: Add support for color matrix input. * scripts/plot/meshz.m: Add support for color matrix input. diff -r 1e2641277b2a -r 4b834dbe4b3e scripts/plot/meshz.m --- a/scripts/plot/meshz.m Fri Aug 02 17:40:24 2013 -0700 +++ b/scripts/plot/meshz.m Sat Aug 03 10:05:07 2013 -0700 @@ -64,8 +64,10 @@ ## Find where property/value pairs start charidx = find (cellfun ("isclass", varargin, "char"), 1); + have_c = false; if (isempty (charidx)) if (nargin == 2 || nargin == 4) + have_c = true; charidx = nargin; # bundle C matrix back into varargin else charidx = nargin + 1; @@ -100,6 +102,15 @@ zref .* ones(rows(z), 1), z, zref .* ones(rows(z), 1); zref .* ones(1, columns(z) + 2)]; + if (have_c) + c = varargin{charidx}; + cref = min (c(isfinite (c))); + c = [cref .* ones(1, columns(c) + 2); + cref .* ones(rows(c), 1), c, cref .* ones(rows(c), 1); + cref .* ones(1, columns(c) + 2)]; + varargin(charidx) = c; + endif + oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); unwind_protect hax = newplot (hax); @@ -116,3 +127,18 @@ endfunction + +%!demo +%! clf; +%! colormap ('default'); +%! Z = peaks (); +%! meshz (Z); + +%!demo +%! clf; +%! colormap ('default'); +%! [X,Y,Z] = peaks (); +%! [fx, fy] = gradient (Z); +%! C = sqrt (fx.^2 + fy.^2); +%! meshz (X,Y,Z,C); +