force a number of tick marks in a matlab plot
February 20th, 2008 by Lawrence David
matlab will automatically calculate how many tick marks produce the most pleasing axes in a plot. however, if you know better, you can override these settings by commanding:
>> set(gca,’XTick’,[1:tick_number])
Sorry to say this, but you really got this wrong: XTick sets the location of the ticks, not the number of ticks. If you do
>> plot(-3,-2)
>> set(gca,’XTick’,1:3)
you won’t see any ticks on the x-axis, because Matlab tries to make ticks at x=1,2,3. But this is not visible in the current plot, so no ticks are produced.