File Exchange

image thumbnail

matlabfrag to pdf

version 1.4 (2.98 KB) by

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

4.66667
3 Ratings

5 Downloads

Updated

View License

Based on plotpdftex

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

USAGE:
------------------------

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.

Comments and Ratings (10)

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.

Ralf

tobsen

tobsen (view profile)

UPDATE -----

Just found out it works with

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

or

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

Sorry for wasting your time :)

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;
end

figH=figure;
plot(Q,h);
xlabel('Flow (m³/s)');
ylabel('Stage (m above sea level)');
colormap summer;

mlf2pdf(figH,'rating-curve');

Regards,
Tobsen

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.

Regards,
Ralf

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.

David

David (view profile)

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

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.

http://www.mathworks.com/matlabcentral/answers/850-matlab-environment-variables

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!

Ralf

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?

Ralf

Ralf (view profile)

Martin

Martin (view profile)

Thanks to Ralf for the UNIX commands...

Updates

1.4

+ added UNIX Support
+ included an example

1.2

mlf2pdf ignored the figure handle. Should work now.

1.1

added acknowledgements

MATLAB Release
MATLAB 7.8 (R2009a)

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

» Watch video