home *** CD-ROM | disk | FTP | other *** search
- function h = waterfall(x,y,z,c)
- %WATERFALL Waterfall plot.
- % WATERFALL(...) is the same as MESH(...) except that the column lines of
- % the mesh are not drawn - thus producing a "waterfall" plot, and the
- % matrices are transposed so that they are oriented correctly for
- % column-oriented data analysis.
- %
- % See also MESH.
-
- % Copyright (c) 1984-93 by The MathWorks, Inc.
-
- a = newplot;
- if nargin == 1
- z = x;
- c = z;
- x = 1:size(z,2);
- y = 1:size(z,1);
- elseif nargin == 2
- z = x;
- c = y;
- x = 1:size(z,2);
- y = 1:size(z,1);
- elseif nargin == 3
- c = z;
- end
- if min(size(x)) == 1 | min(size(y)) == 1
- [x,y]=meshgrid(x,y);
- end
-
- % add another data point at beginning and end of each row for a patch.
- x = [x(:,1) x x(:,size(x,2)) (x(:,1)+x(:,size(x,2)))/2];
- y = [y(:,1) y y(:,size(y,2)) (y(:,1)+y(:,size(y,2)))/2];
- z = z - norm(z,1)/1e7;
- c0 = min(min(c));
- % don't really want this but need it for zlim(1);;
- hh = plot3([min(x(:)) max(x(:))],[min(y(:)) max(y(:))],[min(z(:)) max(z(:))]);
- ax = get(a,'zlim');
- delete(hh);
- z = [ax(1)*ones(size(x,1),1) z ax(1)*ones(size(x,1),2) ];
- c = [c0*ones(size(x,1),1) c c0*ones(size(x,1),1) nan*ones(size(x,1),1)];
- fc = get(gca,'color');
- if strcmp(fc,'none'), fc = get(gcf,'color'); end
- hp = patch(x',y',z',c','facecolor',fc,'edgecolor','interp');
-
- % return handles, if requested
- if nargout > 0
- h = hp;
- end
-