MATLAB: In MATLAB, is there a way to set the GRID at a spacing different from the ticks on the axes

alternativeaxesdifferentgridMATLABminorputsetspacingticks

In MATLAB, is there a way to set the GRID at a spacing different from the ticks on the axes?

Best Answer

Currently the ticks and grid line spacing are associated and so the only way to change grid spacing is to change the tick spacing. Here are some examples:
figure
plot(1:100)
set(gca,'xtick',[0:13:100])
set(gca,'ytick',linspace(0,100,13))
% The following code changes the minor grid
% spacing by adjusting the tick spacing:
figure
plot(1:100);
grid on
grid minor
set(gca,'xtick',[0:50:100])
set(gca,'ytick',[0:50:100])