# [Tex/LaTex] Drawing MATLAB plots in Latex

elsarticlegraphics

I have some 2D and 3D figures in MATLAB. Below are two samples of the same kind-

and

How to include these figures in LaTeX? Till now I am including the exported PNG image but that doesn't look smooth while the document is zoomed in.

Check out Matlab2TikZ. This uses TikZ to generate the figures at compile-time.

On the matlab side, you use code like this:

matlab2tikz( '/PATH/FILE.tikz','height','\figureheight','width','\figurewidth',...
'extraAxisOptions',{'tick label style={font=\footnotesize}'}, ...
'extraAxisOptions',{'y tick label style={/pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd}'});


And on the LaTeX side, code like this:

\begin{figure}[htbp]
\centering
\setlength\figureheight{8cm}
\setlength\figurewidth{0.8\textwidth}
\input{PATH/FILE.tikz}
\caption{Caption Text.}
\label{fig:figureLabel}


\end{figure}

Here's an example (a loglog plot with legend, annotations and individual symbols).