MATLAB: Unable to reverse the order of numbers on the Y-axis

axismatlab codery lables

plot(1,a)
bar3c(flipud(dam_tot(:,:,a)))
colorbar;
colormap(jet);
caxis([0 0.1]);
set(gca,'XTick',[1:1:11]);
set(gca,'XTickLabels',round((minSpeedRef:speed_range/(resolution-1):maxSpeedRef)));
xtickangle(-45)
set(gca,'YTick',[1:1:11]);
ax.YDir = 'reverse';
set(gca,'YTickLabels',round(flipud((minTorqueRef:torque_range/(resolution-1):maxTorqueRef))));
ytickangle(45)
xlabel('Speed');
ylabel('Torque');
title(strcat(fname{a},' Damage per Load Case'),'fontsize',14);
set(gcf,'units','inches','position',[0 .5 7 5.5])
set(gca,'FontSize',12)

Best Answer

Your line
ax.YDir = 'reverse';
is not actually doing what you think it is doing. You should add the following line before it.
ax = gca;
ax.YDir = 'reverse';
or use set()
set(gca, 'YDir', 'reverse');
Your code is not giving an error because it is a valid MATLAB syntax. It creates a new struct object with field YDir.