My question is: How can I use Latex mathbb fonts in Matlab.
Furthermore, I have no rights to change Matlab files on my PC.
I do not want to use psfrag, suggested sometimes as a solution, since some of my figures generated with Matlab are pictures and they get really big if they are exported to eps.
I am using Matlab 2017a.
Note:
This is a follow up question to How do you use the LaTeX blackboard font in MATLAB?.
The answer to this question seems outdated. My
MATLAB root\toolbox\matlab\graphics file contains no matlab commands anymore; it seems to be a precompiled file now.
Thus the approach from the original does not work.
Related
This question already has an answer here:
How use pcode to regenerate a file in MatLab?
(1 answer)
Closed 6 years ago.
I have Matlab toolbox contains files with .p suffix.
I've set path it but when I've run main files of toolbox this error appeared :
p was generated prior to MATLAB version 7.5 (R2007b) and is
no longer supported. Use pcode to regenerate the file using MATLAB R2007b or later.
Is there any way to use this toolbox for newer versions of matlab like 2011 or newer?
A p-code file is an obfuscated version of an m-file that should not be readable by the recipient; however, MATLAB is still able to read and interpret these files as though they were the original (unobfuscated) m-files.
As the error states, an older version of MATLAB was used to generate the p-code files you have and therefore it may not be compatible with the version of MATLAB that you are using.
You would need to get a copy of the original m-files as there is no reliable way to "recompile" a p-code file. You would need to run pcode on the original m-files to generate new/compatible p-files.
This may require that you get in touch with the original developer.
That being said, it should just be a warning and you should be able to still use the files with the caveat that there may be unexpected behavior.
I'm trying to run some of the Matlab code I have right now in Octave. (I know Octave doesn't support all Matlab code) In particular I am trying to run
xlabel('Frequency in $\pi$ units','Interpreter','LaTex')
However I get an error telling my Octave doesn't support the Latex interpreter. I found a workaround online but it is specific to Windows and I am running Linux Mint 14. I was wondering if anyone knew a workaround for Linux, using gnuplot I suppose (or anything else that gets the job done!).
This answer depends on your version of octave.
Set the label as you've done:
xlabel('Whatever')
ylabel('Whenever')
Then print your answer to a latex file:
print -dpslatex 'filename'
It is not perfect and the font size cannot be changed, but it is a solution.
Is it possible to have Matlab editor, without having the whole Matlab?
The warnings that Matlab editor provides are useful for me in coding, but I can not afford buying Matlab. How can I only use the editor? Does it still give warnings?
You could use GNU Emacs. Configure Emacs Octave Support. Then M files, within Emacs, will have syntax highlighting and indentation. You will not have in-editor warnings as in the MATLAB editor.
You could use Octave to run and test your M files. For simple scripts and functions, little to no modifications will be required to go from MATLAB to Octave, or vice versa. The same is not true for MATLAB code that implements GUIs or some of the more specialized toolbox.
You could certainly use a text editor to edit matlab files, as long as you save them with the .m extension. Unfortunately, as Matlab is the only program that can interpret the file, you won't get warnings as you work.
As an alternative, you could get FreeMat (http://freemat.sourceforge.net/) and work with .m files with proper syntax highlighting. However, FreeMat does not have the vast library of functions that Matlab has, and still won't provide you with warnings as you code.
Maybe you could work with Matlab in your institution's library (if you're a student), or get your business to pay for it (if you're a professional)?
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'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.