# MATLAB: How to Display Grid Lines with Specific Distance from One Another

grid linesplot

I want grid lines for a plot but MATLAB automatically define the number of grid lines. Is there any way to manually define the number of grid lines for a plot?

   number_interior_x_gridlines = 7;   ax = gca;   XL = get(ax, 'XLim');   xticks_at = linspace(XL(1), XL, number_interior_x_gridlines + 2);   set(ax, 'XTick', xticks_at);