View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
matlabfrag to pdf

4.7 | 3 ratings Rate this file 10 Downloads (last 30 days) File Size: 2.98 KB File ID: #28545 Version: 1.4

matlabfrag to pdf


Martin (view profile)


25 Aug 2010 (Updated )

Small script using matlabfrag to create a latex formatted pdf file.

| Watch this File

File Information

Based on plotpdftex

Calls matlabfrag to create the *.eps and *.tex Files. After that pdflatex is used to create the pdf File.


    mlf2pdf creates the PDF file of the current graphical figure (CGF)
    named LaTeXfile.pdf
    mlf2pdf(H) creates the PDF file from the graphical figure with
    handle H, named LaTeXfile.pdf
    mlf2pdf(H,FILENAME) creates the PDF file from the graphical figure
    with handle H, named FILENAME.PDF (FILENAME is a character array of
    the filename, with or without the extension .PDF)
    mlf2pdf(H,FILENAME,PACKAGES) to adding
    packages such as fonts, mathfont,...
    ex: PACKAGES = 'amssymb, times'

It now supports Windows AND Unix Systems.


Plot Pdf Tex and Matlabfrag inspired this file.

This file inspired Latexfigure and Huygens Fresnel Integral Approximation, Free Form Apertures And Rough Surfaces.

MATLAB release MATLAB 7.8 (R2009a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (10)
06 Oct 2011 Ralf

Ralf (view profile)

Oh, that's no problem tobsen. You were quicker than I. What you just figured out by yourself I wanted to suggest you.

You not need to set the interpreter, because mlf2pdf is using pdflatex anyway.

Have fun with Matlab and LaTeX.


Comment only
06 Oct 2011 tobsen

tobsen (view profile)

UPDATE -----

Just found out it works with

xlabel('Flow ($m^3/s$)','Interpreter','Tex');


xlabel('Flow ($m^3/s$)','Interpreter','LaTex');

Sorry for wasting your time :)

Comment only
06 Oct 2011 tobsen

tobsen (view profile)

Thanks Ralf for the quick reply, I'm rather new to Matlab, so maybe I did something wrong, but the code that doesn't work is this:

% plot water level over flow (Q)
Q = 200:100:50000;
h = zeros(498,1);
j = 1;
for i=200:100:50000
h(j) = river_stage(i);
j = j + 1;

xlabel('Flow (m³/s)');
ylabel('Stage (m above sea level)');
colormap summer;



Comment only
05 Oct 2011 Ralf

Ralf (view profile)

Hi tobsen,

it is difficult to say what went wrong in your example. Could you please post the relevant code? Do you use $$-enviroment? For me, superscripts work perfectly.


Comment only
05 Oct 2011 tobsen

tobsen (view profile)

Good work! There is a problem with superscript letters though. I was trying to plot a graph with 'Hm³' in the x-axis text and couldn't get the export to run. I have no idea how to fix this, but I thought it would be nice if someone did.

29 Mar 2011 David

David (view profile)

I added the location using file set path. Everything is working perfectly now. Thanks

28 Mar 2011 Ralf

Ralf (view profile)

Hi David! I had a similar issue, when I moved my scripts from my Ubuntu machine to Mac OS X. I guess mlf2pdf do not find pdflatex on your machine.

At that time Walter Robertson helped me with this problem.

This solution is for a Unix OS, but for Windows you also have set the path for pdflatex in the startup.m file.

Good luck!


Comment only
28 Mar 2011 David

David (view profile)

I dont know if this is the correct place to ask questions, but...

I had mlf2pdf running on my old machine and have recently upgraded to win7 64bit. Now when I call mlf2pdf it goes through the motions and i see the eps and tex file being generated but the pdf file never materializes despite the output from mlf2pdf being good.

Has anyone else experienced this?

Comment only
08 Feb 2011 Ralf

Ralf (view profile)

14 Sep 2010 Martin

Martin (view profile)

Thanks to Ralf for the UNIX commands...

Comment only
25 Aug 2010 1.1

added acknowledgements

03 Sep 2010 1.2

mlf2pdf ignored the figure handle. Should work now.

14 Sep 2010 1.4

+ added UNIX Support
+ included an example

Contact us