MATLAB: How to reverse the y-axis in image

axis

The image function reverses the y-axis so I wanted to reverse it to correct it. I know it has something to do with gca but cannot figure out the right code. Please help me.

Best Answer

You can change the direction of increasing values along the y-axis by setting the YDir property of the Axes object.
If you want the values to increase from bottom to top (2-D view), then set the value to 'normal'. Alternatively, if you want the values to decrease from bottom to top, then set the value to 'reverse'. For example:
ax = gca;
ax.YDir = 'normal'