4

I have some Matlab code that produces some diagrams. All I want to do, is to import these diagrams into TeXmaker. In which format do I have to save these diagrams and what packages do I need for this purpose?

Torbjørn T.
  • 206,688
john john
  • 191
  • 1
    The best option is to export it as eps or pdf. Then you can include it in tex file using graphicx package. – Sigur Dec 29 '13 at 14:33
  • 1
    I prefer PDF, but as the PDF export from Matlab sucks big time, an extra step should be taken. See http://tex.stackexchange.com/questions/5559/, http://tex.stackexchange.com/questions/3995/ or http://tex.stackexchange.com/questions/34386/. – Torbjørn T. Dec 29 '13 at 15:28
  • 1
    How about exporting the figure using matlab2tikz, and include the exported code in as a tikzpicture in LaTeX? – Herr K. Dec 29 '13 at 18:10
  • I usually export from GIMP as png but I don't know if that's an option for MatLab. (On OS X, exporting as pdf worked at least as well, but on Linux exporting as png generally works better.) png has considerable advantages if I'm planning to use an image in beamer, for example, because the support for transparency is better. – cfr Dec 29 '13 at 23:33
  • 1
    @cfr Yes, one can export as PNG from Matlab, but you generally don't want that, as PNG is a raster format, while EPS and PDF are vector formats. – Torbjørn T. Dec 30 '13 at 11:42
  • @Torbjørn T.You made a great point about the importance of using vector formats. However, PDF is documents format not the image one and PDF documents can contain both roster and vector graphic. EPS and PostScript in general is great page description language which produces vector output and I have yet to understand the preference of many users for PDF format. – Predrag Punosevac Dec 31 '13 at 22:39
  • @PredragPunosevac I'm aware that PDF can contain both raster and vector graphics, I was a bit inaccurate. However, when saving Matlab figures as PDF you get a vector file. Further, when using pdflatex, as most do these days, EPS files has to be converted to PDF anyway. For those still using the DVI route, PDF is of course not an option. – Torbjørn T. Dec 31 '13 at 23:40

2 Answers2

0

You will want to export images in EPS format and use graphicx package to include them in your TeX document. If you need to make labels and and add formulas to your images you will need PSfrag package.

-1

I use Sage math for Ubuntu and the both may have one or more things in common. Generate an EPS and a PDF format for the same diagram and then use the \includegraphics in the file.tex. But in Sage though you don't need any command it does it for you.

Torbjørn T.
  • 206,688
Xrobot
  • 153
  • 1
    I had hard time refraining from down voting your answer. The guy is asking about MATLAB and out of nowhere you start talking about Sage. – Predrag Punosevac Dec 31 '13 at 22:33
  • My bad. But I have both softwares and they are pretty much similar. I didn't try your answer though – Xrobot Jan 08 '14 at 08:51
  • There is no similarity between Sage and MATLAB! You probably want to refrain from posting invalid statements on the Internet. You never know when that can hurt you. – Predrag Punosevac Jan 09 '14 at 20:15