Newsletters - MATLAB News & Notes
MATLAB Tips & Tricks:
Printing and Exporting Graphics
Tech Support answers three frequently asked questions
by Rob Monteiro
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Welcome to MATLAB Tips & Tricks, a column devoted to answering the most commonly asked questions received by The MathWorks technical support team. In this edition of News & Notes , we discuss the intricacies our customers encounter the most when attempting to print or export graphics from MATLAB. How can I use device options such as PostScript and Ghostscript and still specify the printer?
print -PNike -dps On Windows, there is an option, -v, that allows the Print dialog box to open. Again, this can be used in conjunction with any device drivers. For example, print-v -dwinc allows you to choose a printer through the dialog box (the same dialog box that opens when you pull down the File menu and select Print) using the -dwinc driver. This command is most useful in GUI applications where the designer wants you to have flexibility in choosing a printer but to use a specific driver that MATLAB provides. For MATLAB 5.2 and earlier, please refer to the manual Using MATLAB Graphics for information on capturing printer ports. Please note that in MATLAB 5.3 (to be released in the future), the process of capturing ports will be much easier, as MATLAB will recognize your default Windows printers. How can I avoid segmentation violations, bus errors, floating point exceptions, and illegal instructions when printing?
How do I import MATLAB graphics into Microsoft Office 97?These tips are tailored towards Microsoft Word. Most will also work for PowerPoint, but some of the actions specific to importing figures may be different. The most common way of exporting MATLAB graphics on the PC is to go to the Figure window, select the Edit menu, and choose Copy. This will send the figure into the Windows clipboard as an enhanced metafile. Then, in the appropriate part of the Word document, pull down the Edit menu and choose Paste. You may want to perform this function in an M-file or in a callback for a GUI directly from the command line. This can be done with the command print -dmeta This command will put the current figure into the clipboard as an enhanced metafile (EMF). You can then paste the figure into Word as noted above. Because of a bug in Office 97 on the Windows 95 platform (see Microsoft Knowledge Base Article ID# Q158889), MATLAB graphics exported to Office 97 will not always print properly. We suggest importing figures into Word using the following alternatives: print -zbuffer -dmeta [or] print -zbuffer -dmeta filename
print -deps filename In Word, select the Insert menu, and then choose Picture. In the next submenu, choose From File and Browse until you find filename.eps. Then, print your Word document to a PostScript printer using a PostScript printer driver. MATLAB 5.1 provides the capability of adding a tiff preview to this file. However, in MATLAB 5.0 and earlier, there is no way to add a preview to EPS files, so you will only see a bounding box when you import into Word. To generate the preview with the EPS file, use the following syntax: print -deps filename -tiff Then, import the figure into Word by using the method described above. Tech SupportTo access the Tech Support area on the Web and search the same database that our technical support engineers use, visit www.mathworks.com and select Tech Support Solution Search. |
Store




