home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / PLOTXYZ.DI$ / MESH.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  2.8 KB  |  91 lines

  1. function h = mesh(x,y,z,c)
  2. %MESH    3-D mesh surface.
  3. %    MESH(X,Y,Z,C) plots the colored parametric mesh defined by
  4. %    four matrix arguments.  The view point is specified by VIEW.
  5. %    The axis labels are determined by the range of X, Y and Z,
  6. %    or by the current setting of AXIS.  The color scaling is determined
  7. %    by the range of C, or by the current setting of CAXIS.  The scaled
  8. %    color values are used as indices into the current COLORMAP.
  9. %
  10. %    MESH(X,Y,Z) uses C = Z, so color is proportional to mesh height.
  11. %
  12. %    MESH(x,y,Z) and MESH(x,y,Z,C), with two vector arguments replacing
  13. %    the first two matrix arguments, must have length(x) = n and
  14. %    length(y) = m where [m,n] = size(Z).  In this case, the vertices
  15. %    of the mesh lines are the triples (x(j), y(i), Z(i,j)).
  16. %    Note that x corresponds to the columns of Z and y corresponds to
  17. %    the rows.
  18. %
  19. %    MESH(Z) and MESH(Z,C) use x = 1:n and y = 1:m.  In this case,
  20. %    the height, Z, is a single-valued function, defined over a
  21. %    geometrically rectangular grid.
  22. %
  23. %    MESH returns a handle to a SURFACE object.
  24. %
  25. %     AXIS, CAXIS, COLORMAP, HOLD, SHADING and VIEW set figure, axes, and 
  26. %     surface properties which affect the display of the mesh.
  27. %
  28. %     See also SURF, MESHC, MESHZ, WATERFALL.
  29.  
  30. %-------------------------------
  31. %    Additional details:
  32. %
  33. %    MESH sets the FaceColor property to background color and the EdgeColor
  34. %    property to 'flat'.
  35. %
  36. %    If the NextPlot axis property is REPLACE (HOLD is off), MESH resets 
  37. %    all axis properties, except Position, to their default values
  38. %    and deletes all axis children (line, patch, surf, image, and 
  39. %    text objects).
  40.  
  41. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  42.  
  43. %    J.N. Little 1-5-92
  44. %    Modified 2-3-92, LS.
  45.  
  46. user_view = 0;
  47. cax = newplot;
  48. fc = get(gca,'color');
  49. if strcmp(lower(fc),'none')
  50.     fc = get(gcf,'color');
  51. end
  52.  
  53. if nargin == 1
  54.     hh = surface(x,'FaceColor',fc,'EdgeColor','flat');
  55. elseif nargin == 2
  56.         if isstr(y), error('Invalid argument.'); end
  57.     [my ny] = size(y);
  58.     [mx nx] = size(x);
  59.     if mx == my & nx == ny
  60.         hh = surface(x,y,'FaceColor',fc,'EdgeColor','flat');
  61.     else
  62.         if my*ny == 2 % must be [az el]
  63.             hh = surface(x,'FaceColor',fc,'EdgeColor','flat');
  64.             set(gca,'View',y);
  65.             user_view = 1;
  66.         else
  67.             error('Invalid input arguments.');
  68.         end
  69.     end
  70. elseif nargin == 3
  71.         if isstr(y) | isstr(z), error('Invalid argument.'); end
  72.     if min(size(y)) == 1 & min(size(z)) == 1 % old style
  73.         hh = surface(x,'FaceColor',fc,'EdgeColor','flat');
  74.         set(gca,'View',y);
  75.         user_view = 1;
  76.     else
  77.         hh = surface(x,y,z,'FaceColor',fc,'EdgeColor','flat');
  78.     end
  79. elseif nargin == 4
  80.     hh = surface(x,y,z,c,'FaceColor',fc,'EdgeColor','flat');
  81. else
  82.     error('Requires 1, 2, 3, or 4 input arguments.');
  83. end
  84. next = lower(get(cax,'NextPlot'));
  85. if ~ishold & ~user_view
  86.     view(322.5,30);
  87. end
  88. if nargout == 1
  89.     h = hh;
  90. end
  91.