MATLAB: How to: Axis Xtick steps

axis step size xtick

I plot something and Matlab auto chooses the axis step as 5, I want it 1.
how can i say that the step size should be 1.
I know you can use:
set(gca,'YTick',[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 etc]);
but this is just too long 🙂

Best Answer

xbounds = xlim;
set(gca,'XTick',xbounds(1):xbounds(2));