meta data for this page
Matlab Hints and Links
You can find Matlab documentation at MathWorks site. Other available information sources:
- Newsgroup comp.soft-sys.matlab. Read at Math Forum.
- Matlab documentation generator: Generate HTML documentation from m-files.
- Matlab Compiler: How to compile your Matlab demo to a Linux binary and run it.
- Matlab Image Toolbox: There are very few Image Toolbox licences (8). How to avoid using Image Toolbox.
Try to compile your m-files to C and standalone binary code, it will reveal many stupid bugs. Check the
Saving figures for articles
Currently the easiest way to produce useful figures is to use export_fig. You can get the script from Matlab Central: export_fig (just download, unpack and use). If you are still unhappy, then you need to hack Matlab saveas() or print() yourself.
It is suggested to use pdflatex as a tex compiler. This approach requires pdf files which can be produced by first exporting all your figures as eps and then converting them with epstopdf.
To create nice EPS-files from figures you can use something like this:
print(figure_handle, '-depsc2', '-r600', '-painters', file_name);
This creates Encapsulated PostScript level 2 in colors using vector drawing and optimizing for 600 ppi print resolution. Notice that this is primarily for vector graphics. If you have only pixel-based images (pixmaps), painters mode may create unnecessarily huge files, so you should try the Z-buffer mode, which creates pixmaps. If you need mixed vector graphics and pixmaps, you have to try what is best wrt. file size and quality. For instance, downscale the pixmaps in Matlab before plotting them into a figure and then print in painters mode. Painters mode most likely renders every pixel in a pixmap with a colored quadrilateral. Also notice that 600 ppi is huge, normal screen resolution is 75-120 ppi, and usual print resolution is 300 ppi. Required ppi depends on the print quality you want.
If Matlab inverts marker colors in figures when printing and that's bad, try
Remember to select colormaps, so that they look nice also when converted to gray scale: http://blogs.mathworks.com/steve/2006/05/09/a-lab-based-uniform-color-scale/ (a related colormap generator: http://bsp.pdx.edu/Software/ColorSpiral.m)
In the end you can convert your eps files to pdf files (with a same basename) with
How to show a single channel image with undetermined values as holes:
image(img, 'CDataMapping', 'scaled', 'AlphaData', ~isnan(img));