function h=mypcolor2(x,y,z)
% mypcolor2(x,y,z)   similar to pcolor but fixes
%                    some annoying matlab quirks

nx=length(x);
x2=[2*x(1)-x(2); x(:)];
x2(1:nx)=(x2(1:nx)+x2(2:(nx+1)))/2;
x2(nx+1)=2*x2(nx)-x2(nx-1);

ny=length(y);
y2=[2*y(1)-y(2); y(:)];
y2(1:ny)=(y2(1:ny)+y2(2:(ny+1)))/2;
y2(ny+1)=2*y2(ny)-y2(ny-1);

z2=zeros(length(x2),length(y2));
z2(1:nx,1:ny)=z;

pcolor(x2,y2,z2'); shading flat
