%% Create Plot Titles, Tick Labels, and Legends with LaTeX
% You can use LaTeX markup in plot titles, tick labels, and legends. For example, create a plot of a sine wave and a cosine wave.

x = -10:0.1:10;
y = [sin(x); cos(x)];
plot(x,y)

%
% Set the x-axis tick values to be multiples of pi by calling the xticks function. Then, call the gca function to get the current axes, and set the the TicklabelInterpreter property to 'latex'. Specify the tick labels using LaTeX markup. For inline expressions, surround the markup with single dollar signs ($).

xticks([-3*pi -2*pi -pi 0 pi 2*pi 3*pi])
ax = gca;
ax.TickLabelInterpreter = 'latex';
xticklabels({'$-3\pi$','$-2\pi$','$-\pi$','0', '$\pi$','$2\pi$','$3\pi$'});

%
% Add a title that includes LaTeX markup by calling the title function and setting the Interpreter property to 'latex'. Similarly, create a legend with labels that include LaTeX markup.

% Add title
str = 'Estimates $\hat{\psi_1}$ and $\hat{\psi_2}$';
title(str,'Interpreter','latex')

% Add legend
label1 = '$\hat{\psi_1}$';
label2 = '$\hat{\psi_2}$';
legend(label1,label2,'Interpreter','latex')

% Copyright 2020 The MathWorks, Inc.