MATLAB Function Reference | Search  Help Desk |
print, printopt | Examples See Also |
print print -devicetype
-options
filename
[pcmd,dev] = printopt
print
and printopt
produce hardcopy output. All arguments to the print
command are optional. You can use them in any combination or order.
print
sends the contents of the current Figure, including bitmap representations of any user interface controls, to the printer using the device and system print command defined by printopt
.
print -devicetype
specifies a device type, overriding the value returned by printopt
. The Devices section lists all supported device types.
print -options
specifies print options that modify the action of the print
command. (For example, the -noui
option suppresses printing of user interface controls.) The Options section lists available options.
print filename
directs the output to the file designated by filename
. If filename
does not include an extension, print
appends an appropriate extension, depending on the device (e.g., .eps
). If you omit filename
, print
sends the file to the default output device (except for -dmeta and -dbitmap, which place their output on the clipboard).
[pcmd,dev] = printopt
returns strings containing the current system-dependent print command and output device. printopt
is an M-file used by print
to produce the hardcopy output. You can edit the M-file printopt.m
to set your default printer type and destination.
pcmd
and dev
are platform-dependent strings. pcmd
contains the command that print
uses to send a file to the printer. dev
contains the device option for the print
command. Their defaults are platform dependent.Platform |
pcmd |
dev |
UNIX |
|
|
VMS |
|
|
Windows |
COPY /B %s LPT1: |
-dwin |
Macintosh |
(not applicable) |
-dps2 |
printopt.m
file.
The TIFF image format is supported on all platforms by almost all word processors for importing images. JPEG is a lossy highly compressed format that is supported on all platforms for image processing and for inclusion into HTML documents on the World Wide Web. To create these formats, MATLAB renders the Figure using the Z-buffer rendering method and the resulting pixmap is then saved to the specified file. You can specify the resolution of the image using the -r
resolution switch.Device |
Description |
|
Create PICT file |
-v |
Verbose mode to display Print dialog box (suppressed by default) |
print
command. Option |
Description |
|
Add color TIFF preview to Encapsulated PostScript |
|
Use loose bounding box for EPS and PS devices |
|
Use CMYK colors in PostScript instead of RGB |
|
Append to existing PostScript file without overwriting |
|
Specify resolution in dots per inch |
|
Use PostScript default character set encoding |
|
Specify printer to use (UNIX only) |
|
Handle of a Figure graphics object to print (current Figure by default; see gcf ) |
|
Name of SIMULINK system window to print (current system by default; see gcs ) |
-painters |
Render using painter's algorithm |
-zbuffer |
Render using Z-buffer |
-noui |
Suppress printing of user interface controls |
PaperType
property of the Figure or selecting a supported paper sizes from the print dialog box:Troubleshooting MS-Windows Printing
If you encounter problems such as segmentation violations , general protection faults, application errors, or the output does not appear as you expect when using MS-Windows printer drivers, try the following:print
command: they all start with -dps
, or -deps
.
print
-dmeta
option at the command line. You can then import the file into another application for printing.
You can set copy options in the Figure's File-->Preferences...-->Copying Options dialog box. The Windows Metafile clipboard format produces a better quality image than Windows Bitmap.
Printing Thick Lines on Windows95
Due to a limitation in Windows95, MATLAB is set up to print lines as either:LineWidth
)
LineStyle
)matlab.ini
file, which is in your Windows directory. In this file, find the section:
[Matlab Settings]and in this section change the assignment,
ThinLineStyles=1to
ThinLineStyles=0then restart MATLAB. You can generally obtain better results when printing a Figure window that contains MATLAB
uicontrol
s
by setting these key properties:
PaperPositionMode
property to auto
. This ensures the printed version is the same size as the onscreen version. With PaperPositionMode
set to auto
MATLAB does not resize the Figure to fit the current value of the PaperPosition
. This is particularly important if you have specified a Figure ResizeFcn
because if MATLAB resizes the Figure during the print operation, the ResizeFcn
is automatically called.
To set PaperPositionMode
on the current Figure, use the command:
set(gcf,'PaperPositionMode','auto')
InvertHardcopy
property to off
. By default, MATLAB changes the Figure background color of printed output to white, but does not change the color of Uicontrols. If you have set the background color to, for example, match the gray of the GUI devices, you must set InvertHardcopy
to off
to preserve the color scheme.
To set InvertHardcopy
on the current Figure, use the command:
set(gcf,'InvertHardcopy','off')
print
command's -loose
option to prevent MATLAB from using a bounding box that is tightly wrapped around objects contained in the Figure. This is important if you have intentionally used space between Uicontrols or Axes and the edge of the Figure and you want to maintain this visual appearance in the printed output.
Notes on Printing Interpolated Shading with PostScript Drivers
MATLAB can print Surface objects (such as graphs created withsurf
or mesh
) using interpolated colors. However, only Patch objects that are composed of triangular faces can be printed using interpolated shading.
Printed output is always interpolated in RGB space, not in the colormap colors. This means, if you are using indexed color and interpolated face coloring, the printed output can look different from what is displayed on screen. See "Interpolating in Indexed vs. Truecolor" in the Using MATLAB Graphics manual for an illustration of each type of interpolation.
PostScript files generated for interpolated shading contain the color information of the graphics object's vertices and require the printer to perform the interpolation calculations. This can take an excessive amount of time and in some cases, printers may actually "time-out" before finishing the print job. One solution to this problem is to interpolate the data and generate a greater number of faces, which can then be flat shaded.
To ensure that the printed output matches what you see on the screen, print using the -zbuffer
option. To obtain higher resolution (for example, to make text look better), use the -r
option to increase the resolution. There is, however, a trade-off between the resolution and the size of the created PostScript file, which can be quite large at higher resolutions. The default resolution of 150 dpi generally produces good results. You can reduce the size of the output file by making the Figure smaller before printing it and setting the Figure PaperPositionMode
to auto
, or by just setting the PaperPosition
property to a smaller size.
Note that in some UNIX environments, the default lpr
command cannot print files larger than 1 Mbyte unless you use the -s
option, which MATLAB does by default. See the lpr
man page for more information.
This example prints a surface plot with interploted shading. Setting the current Figure's (gcf
) PaperPositionMode
to auto
enables you to resize the Figure window and print it at the size you see on the screen. See Options and the previous section for information on the -zbuffer
and -r200
options.
surf(peaks) shading interp set(gcf,'PaperPositionMode','auto') print -dpsc2 -zbuffer -r200
orient
, figure
See the Using MATLAB Graphics manual for detailed information about printing in MATLAB.