File Exchange

image thumbnail

matlabfrag to pdf

version (2.98 KB) by Martin
Small script using matlabfrag to create a latex formatted pdf file.


Updated 14 Sep 2010

View Version History

View License

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.

Cite As

Martin (2020). matlabfrag to pdf (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (12)

Mazin Mustafa

Any idea what does this mean?
The system cannot find the file specified

Mazin Mustafa

Can you help with the labels and title they are all gone!!


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.



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 :)


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;




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.



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.


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


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!



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?



Thanks to Ralf for the UNIX commands...

MATLAB Release Compatibility
Created with R2009a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: PlotPdfTex, matlabfrag

Inspired: latexfigure

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!