[Tex/LaTex] Drawing MATLAB plots in Latex


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

enter image description here


enter image description here

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.

Best Answer

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:

\caption{Caption Text.}


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

A loglog plot from Matlab with legend and individual symbols and annotations