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

  1. function h = surf(x,y,z,c)
  2. %SURF    3-D shaded surface graph.
  3. %    SURF(X,Y,Z,C) plots the colored parametric surface 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. %    The shading model is set by SHADING.
  10. %
  11. %    SURF(X,Y,Z) uses C = Z, so color is proportional to surface height.
  12. %
  13. %    SURF(x,y,Z) and SURF(x,y,Z,C), with two vector arguments replacing
  14. %    the first two matrix arguments, must have length(x) = n and
  15. %    length(y) = m where [m,n] = size(Z).  In this case, the vertices
  16. %    of the surface patches are the triples (x(j), y(i), Z(i,j)).
  17. %    Note that x corresponds to the columns of Z and y corresponds to
  18. %    the rows.
  19. %
  20. %    SURF(Z) and SURF(Z,C) use x = 1:n and y = 1:m.  In this case,
  21. %    the height, Z, is a single-valued function, defined over a
  22. %    geometrically rectangular grid.
  23. %
  24. %    SURF returns a handle to a SURFACE object.
  25. %
  26. %     AXIS, CAXIS, COLORMAP, HOLD, SHADING and VIEW set figure, axes, and 
  27. %     surface properties which affect the display of the surface.
  28. %
  29. %     See also SURFC, SURFL, MESH.
  30.  
  31. %-------------------------------
  32. %    Additional details:
  33. %
  34. %    If the NextPlot axis property is REPLACE (HOLD is off), SURF resets 
  35. %    all axis properties, except Position, to their default values
  36. %    and deletes all axis children (line, patch, surf, image, and 
  37. %    text objects).
  38.  
  39. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  40.  
  41. %    J.N. Little 1-5-92
  42.  
  43. cax = newplot;
  44.  
  45. if nargin == 0
  46.     error('Not enough input arguments.')
  47.  
  48. elseif nargin == 1
  49.     if min( size( x ) ) == 1
  50.         error('Input argument must be a matrix not a vector or a scalar')
  51.     else
  52.         hh = surface(x);
  53.     end
  54.  
  55. elseif nargin == 2
  56.     hh = surface(x,y);
  57.  
  58. elseif nargin == 3
  59.     hh = surface(x,y,z);
  60.  
  61. elseif nargin == 4
  62.     hh = surface(x,y,z,c);
  63.  
  64. else
  65.     error('Too many input arguments.')
  66.  
  67. end
  68.  
  69. next = lower(get(cax,'NextPlot'));
  70. if ~ishold
  71.     view(3);
  72. end
  73. if nargout == 1
  74.     h = hh;
  75. end
  76.