Here are two ways of adding a grid to a plot.
Use the grid function
Use grid on to turn on the axis grid where a grid line will be drawn for every axis tick. Use grid minor to turn on the minor grid lines between axis ticks.
To adjust the spacing of grid lines, change the major and minor axis ticks for each axis.
ax = gca();
Set grid properties (here's a full list). By default the grid is under the plotted data. The line below puts the grid on top, sets the color to red and the minor grid lines to violet.
'MinorGridLineStyle','-','MinorGridColor',[.92 .51 .93],'MinorGridAlpha',1)
Use xline and yline functions
Alternatively, you can use the xline and yline functions to create a grid that is independent of the axis ticks. Since neither of those function accept non-scalar inputs, they must be wrapped in an array function.
ax = gca();
xgrid = 0:0.2:1;
ygrid = 0:0.2:1;
xl = arrayfun(@(x)xline(x,'r-','LineWidth',2),xgrid);
yl = arrayfun(@(y)yline(y,'r-','LineWidth',2),ygrid);
xline and yline produce constantLine objects. Here's a list of their properties. xl and yl will be an array of these objects, one element per line. Here's a demo how to make changes to their properties after plotting.
set(xl, 'LineWidth', 1, 'Alpha', 1)
set(yl, 'LineWidth', 1, 'Alpha', 1)