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

  1. function h = waterfall(x,y,z,c)
  2. %WATERFALL Waterfall plot.
  3. %    WATERFALL(...) is the same as MESH(...) except that the column lines of
  4. %    the mesh are not drawn - thus producing a "waterfall" plot, and the
  5. %    matrices are transposed so that they are oriented correctly for 
  6. %    column-oriented data analysis.
  7. %
  8. %    See also MESH.
  9.  
  10. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  11.  
  12. a = newplot;
  13. if nargin == 1
  14.     z = x;
  15.     c = z;
  16.     x = 1:size(z,2);
  17.     y = 1:size(z,1);
  18. elseif nargin == 2
  19.     z = x;
  20.     c = y;
  21.     x = 1:size(z,2);
  22.     y = 1:size(z,1);
  23. elseif nargin == 3
  24.     c = z;
  25. end
  26. if min(size(x)) == 1 | min(size(y)) == 1
  27.     [x,y]=meshgrid(x,y);
  28. end
  29.  
  30. % add another data point at beginning and end of each row for a patch.
  31. x = [x(:,1) x x(:,size(x,2)) (x(:,1)+x(:,size(x,2)))/2];
  32. y = [y(:,1) y y(:,size(y,2)) (y(:,1)+y(:,size(y,2)))/2];
  33. z = z - norm(z,1)/1e7;
  34. c0 = min(min(c));
  35. % don't really want this but need it for zlim(1);;
  36. hh = plot3([min(x(:)) max(x(:))],[min(y(:)) max(y(:))],[min(z(:)) max(z(:))]);
  37. ax = get(a,'zlim');
  38. delete(hh);
  39. z = [ax(1)*ones(size(x,1),1) z ax(1)*ones(size(x,1),2) ];
  40. c = [c0*ones(size(x,1),1) c c0*ones(size(x,1),1) nan*ones(size(x,1),1)];
  41. fc = get(gca,'color');
  42. if strcmp(fc,'none'), fc = get(gcf,'color'); end
  43. hp = patch(x',y',z',c','facecolor',fc,'edgecolor','interp');
  44.  
  45. % return handles, if requested
  46. if nargout > 0
  47.     h = hp;
  48. end
  49.