# MATLAB: How to specify the spacing between minor tick marks and minor grid lines in the figures in MATLAB

controlMATLAB

I make a plot in MATLAB and then turn on minor grid lines as follows:
plot(1:10)grid minor
The minor grid lines are based on the placing of the minor tick marks. MATLAB automatically calculates the spacing between the minor tick marks. I would like to be able to set these manually in the same manner I can set the placing of major tick marks.

       figure       % specify the minor grid vector       xg = [0:0.025:1];        % specify the Y-position and the height of minor grids       yg = [0 0.1];       xx = reshape([xg;xg;NaN(1,length(xg))],1,length(xg)*3)       yy = repmat([yg NaN],1,length(xg))       h_minorgrid = line(xx,yy,'Color','r')       axis([0 1 0 10])
         plot(1:10);     ax = gca;     ax.XAxis.MinorTick = 'on';     ax.XAxis.MinorTickValues = 1:0.5:10;     grid on;     ax.XMinorGrid = 'on';