matlab2tikz supports the conversion of most MATLAB figures,
including 2D and 3D plots. For plots constructed with third-
party packages, your mileage may vary.
The workflow is as follows.
1. Place matlab2tikz in a directory where MATLAB can find it.
(the current directory, for example).
2. Generate your plot in MATLAB.
3. Invoke matlab2tikz by
>> matlab2tikz( 'myfile.tikz' );
The resulting file can be included into any LaTeX document (by \input{myfile.tikz}). Don't forget to add
\usepackage{pgfplots}
and optionally (as of Pgfplots 1.3)
\pgfplotsset{compat=newest}
\pgfplotsset{plot coordinates/math parser=false}
to the preamble of your LaTeX document.
To specify the dimension of the plot from within the LaTeX document, try
>> matlab2tikz('myfile.tikz', 'height', '\figureheight', 'width', '\figurewidth');
and in the LaTeX source
\newlength\figureheight
\newlength\figurewidth
\setlength\figureheight{4cm}
\setlength\figurewidth{6cm}
\input{myfile.tikz}
For decreasing the output TeX file size, try
cleanfigure;
matlab2tikz('myfile.tex');
and look at the parameter `floatFormat`.
If you would like to see more information, follow the development, submit a bug, or contribute in any other way, please visit matlab2tikz' web page at https://github.com/nschloe/matlab2tikz . |