I'd like to create a PDF out of my matlab m-function. The PDF should contain some text information which I want to style a bit and one image (which is previously generated as figure). Is there any way? The only thing I found is publish to publish source-code. The only alternative I could think off was to programm the texts into the figure window and than export the whole figure to pdf. Perhaps there's a better way to do it?
Thanks!
I would recommend generating your figure with Matlab, outputting it to eps, then converting the figure to pdf using epstopdf. Then embed your figure in a latex document and generate a pdf with pdflatex.
I know this sounds like an incredibly roundabout way of doing it, but
This is the way I've come to do it after years of experience and it always gives me the best results
Every one of my colleagues does it this way for the same reason
The results will be completely reproducible
You're using Matlab to do what it's good at (making scientific figures) and latex to do what it's good at (formatting documents)
The Matlab code to make the eps of the figure would be like this (supposing your figure is figure 1):
print -depsc2 -f1 -loose my_fig.eps
You could pretty easily write a latex template that uses my_fig.pdf and then run everything from your Matlab using bangouts:
!epstopdf my_fig
!pdflatex mydoc.tex
If you're on Windows, you can connect to Word using 'actxserver', insert and style any text you like into a blank document, copy and paste MATLAB figures into the document, and then save it to PDF. You can do all of that from within MATLAB. The first time you do this it's a pain, as you need to learn quite a bit about the Word Object Model; but once you've done it a couple of times it's very simple and quick, and you can achieve very professional results. You can combine this with using the 'export_fig' that others have mentioned.
Related
In a live script in matlab, I plot multiple figures, and I use this code to enumerate the figures:
FigureQuantity=1
plot(data_1)
title('Figure '+string(FigureQuantity))
Then on another code section I do it again
FigureQuantity=FigureQuantity+1
plot(data_n)
title('Figure '+string(FigureQuantity))
The problem is that if I run the last code section again, FigureQuantity gets updated and the enumeration of figures gets broken.
There is any way to get the number of tokens ordered by his code appearance on the live script? (independent of how many times the section code is run)
I would like to keep tokens so I can mix inserted images and plots. And I want to export the document as PDF (not to show plots in an application or an independent window).
What I need is something like MS Word enumeration of figures and tables.
I found this Matlab documentation: Number Section Headings, Table Titles, and Figure Captions Programmatically, but it appears to be used for creation of MS Word or HTML documents, and not to enumerate images on Matlab live scripts.
I do not understand how to use it, or if that is his purpose on Matlab.
I'm assuming you're updating the data_n variable live as well; otherwise, if you're defining these variables manually then not doing so for the figure variables isn't really the solution I think you're looking for.
Why not for-loop through the figure updates?
for FigureQuantity = 1:numberOfFigureQuantities
figure(FigureQuantity);
hold on;
plot(data_n(FigureQuantity))
title(strcat('Figure Number: ',num2str(FigureQuantity)));
end
The figure count corresponding to the FigureQuantity will index the appropriate figure and will update that figure if it already existed. This is the solution I think you're looking for; if not, please clarify.
This is my first post, so apologies if I do something wrong or am not clear.
I am trying to display multiple .fig files in one figure to compare them to each other. I tried using montage() but the education license I am on apparently doesn't have that included.
With montage I did..
comp10 = dir('c:\data_figs\location_1\fig10*.fig');
montage(comp10,'size',[1 NaN]);
Is there a way to do something similar without montage? I'm comparing ultrasound imaging analyses, and want them next to each other in order to see which ones have significant movement and which ones can be thrown out.
I am very inexperienced in matlab, so I probably am missing something super simple.
Thank you!
I'm relatively new to Matlab and currently using it to calculate pressure cards for rapid dynamic applications on RADIOSS.
The function is done and can calculate Time-Pressure points.
For the moment I generated only .ascii files to import as curves into the software but I'd like to directly write a text file readable by RADIOSS. (after conversion)
The formatting I need is very specific and I'd like to know if such a thing is possible to do on Matlab. I've been searching on my own for some time now and didn't find really specific formatting options so I come seeking for your advice.
For example I have n time Arrays Te{1 to n} an n Pressure Arrays Pr{1 to n} the format needed is presented in the image linked. How can it be done if it is possible ?
The sprintf function is quite powerful and should provide all the facilities you need. Having looked at the image you linked, I don't see anything particularly special.
This question was posted on Matlab Central (http://goo.gl/MkU8P) but hasn't gotten any answer. I thought someone here might have a lead.
I use publish() quite a bit to produce online class notes. It's working well but frankly, I find the PNG plots to be of awful quality. I've tried setting figureSnapMethod='antialiased' and that's a bit better but I mostly find the result fuzzy.
What would be awesome is to produce SVG plots. Is there any way to do that? I suppose it would have to involve plot2svg somehow (also from File Exchange) since SVG output seems to be only supported for Simulink models. Or perhaps someone has a better solution using some other high quality format.
before using publish you should set some options to change imageForamt. by default it is set to PNG format which is not good for reports, papers, etc. what you need is a vector graphic image, something like an eps or emf file formats. (in such case it does not matter how much you zoom in , it never becomes fuzzy or low resolution).
Any image format that your installed version of Microsoft Office can import, including 'png' , 'jpg', 'bmp',and 'tiff'. If the 'figureSnapMethod' is 'print',then you can also specify 'eps', 'epsc', 'eps2', 'ill', 'meta',and 'pdf'
for HTML output any format publishes successfully
for latex output any format publishes successfully
I suggest you to use eps, it is the best. and remember SVG is not supported in publish. ;)
you should add this part to your command:
'imageFormat','eps'
I'm running a series of scripts that all import data from different matrix files. It seems that displaying the content of the matrix is taking a lot of time. Normally I would do "more on" and just cancel the display after the first page, but I am doing things automatically here, from the command-line version.
Is there a way to stop Matlab from displaying the content of variables when it loads them? Say, a non-verbose/daemon mode? I couldn't find a way to do it when I searched, but I'm sure there must be one.
Thanks in advance!
Found it! The answer is to add a semicolon (;) at the end of the line, for example:
m=importdata('matrix.txt');
This will prevent it from printing the contents of m.