MATLAB: Inverting Z axis in plot

3d plotsaxissurfsurface

Hi everyone! Im a kinda' noob at matlab and I need help inverting the Z axis on a Suface plot.
The issue I have is that I need to Invert the Z axis WITHOUT inverting the 3D figure. For Example, my Z axis goes from 1 to 0 by .25 steps and the 3D figure looks all right. I need to reverse the axis, I need it from 0 to 1 without altering the 3D figure.
I Plotted a text file as DMLread.
Here is my code:
inundation = dlmread('inundation.txt','',7,0);
nx = dlmread('inundation.txt','',[0 1 0 1]);
ny = dlmread('inundation.txt','',[1 1 1 1]);
%3D map of Run-up%
figure
flip(inundation)
mesh(inundation,'FaceColor','interp')
set(gca, 'Zdir', 'reverse')
title('3D Map of Inundation')
ylabel('Mesh width')
xlabel('Mesh length')
zlabel('Height of water')

Best Answer

You only need to reverse the Z-tick labels. The plot will stay as it was.
Example
x = linspace(-1, 1, 25);
y = linspace(-1, 1, 25);
[X,Y] = meshgrid(x,y);
Z = X.^2 .* Y.^2;
figure(1)
surf(X, Y, Z)
grid on
figure(2)
surf(X, Y, Z)
grid on
zt = get(gca, 'ZTick');
set(gca, 'ZTick',zt, 'ZTickLabel',fliplr(zt))
The plots are the same, but in figure(2). the tick labels are reversed.