2

First of all sorry for my bad english. I want to convert my matlab figure to a latex code (no graphic). I want the latex code. I know its possible. But i dont know how. Of course i can also export my matlab figure to an eps or pdf! But i need from this matlab figure the latex code. i hope you understand my problem. thank you in advance.

2

It is highly recommended to use matlab2tikz for this task. You need to download the package and after plotting your figure in Matlab, you should run the matlab2tikz.m function by:

matlab2tikz('YourLatexFile.tex');

Then you can add YourLatexFile.tex into your LaTeX source code, for example by using \input{YourLatexFile.tex}:

\documentclass{article}

  \usepackage{pgfplots}
  \pgfplotsset{compat=newest}
  %% the following commands are sometimes needed
  \usetikzlibrary{plotmarks}
  \usepackage{grffile}
  \usepackage{amsmath}
  %% you may also want the following commands
  %\pgfplotsset{plot coordinates/math parser=false}
  %\newlength\figureheight
  %\newlength\figurewidth

\begin{document}
  \input{YourLatexFile.tex}
\end{document}

Also there are suitable documentation and examples in their Github page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.