%% Add Title and Axis Labels and Format Ticks
% Plot \sin(x) from -2\pi to 2\pi using a function handle. Display the grid lines. Then, add a title and label the x-axis and y-axis.

fplot(@sin,[-2*pi 2*pi])
grid on
title('sin(x) from -2\pi to 2\pi')
xlabel('x');
ylabel('y');

%
% Use gca to access the current axes object. Display tick marks along the x-axis at intervals of \pi/2. Format the x-axis tick values by setting the XTick and XTickLabel properties of the axes object. Similar properties exist for the y-axis.

ax = gca;
ax.XTick = -2*pi:pi/2:2*pi;
ax.XTickLabel = {'-2\pi','-3\pi/2','-\pi','-\pi/2','0',...
    '\pi/2','\pi','3\pi/2','2\pi'};

% Copyright 2014 The MathWorks, Inc.