explain ax.xgrid='on'; in matlab

ax.XGrid = 'on' is setting the property XGrid of the current axes (ax) to 'on'. This turns on the grid lines for the x-axis.

In MATLAB, the grid lines can help the viewer to make a better sense of the data plotted on the axes.

Here's an example code:

main.m
x = linspace(0,2*pi,100);
y = sin(x);
plot(x,y)
ax = gca;
ax.XGrid = 'on';
75 chars
6 lines

The above code plots a sine curve and turns on the grid lines for the x-axis.

related categories

gistlibby LogSnag