Printing and Exporting Figures with MATLAB    

Printer Drivers

A MATLAB printer driver is code that formats your figure into instructions that your printer understands. This section contains an overview of different types of printer drivers, help on choosing a driver, and detailed information about the different types of drivers, including tips on using. Please refer to the appropriate section listed below.

Specifying a Printer Driver

If you do not indicate a specific printer driver, MATLAB uses the default driver specified in printopt.m. The factory default driver depends on the platform.

Platform
Factory Default Printer Driver
Windows
Black-and-white Windows
UNIX
Black-and-white Level II PostScript

To specify the printer driver on a per figure basis, use:

To change the default driver for all figures, edit printopt.m. See Changing the Default Device and Printing Command for instructions.

Changing the default driver is useful if you frequently use the same driver, or if you use the Windows Print dialog box, which does not enable you to set the driver.

Using the Print Dialog Box to Specify a Driver (UNIX only)

To specify a printer driver for the current figure

  1. From the figure window's File menu, select Print. This invokes the Print dialog box.
  2. Select a printer driver from the Driver list.
  3. Click OK to print your figure.

Using the print Command to Specify a Driver

To specify a nondefault printer driver for the figure you are printing, include the device switch, -d, with the print command. This example prints the current figure using MATLAB's built-in Windows color printer driver.

Changing the Default Device and Printing Command

The printopt.m file in your toolbox\local directory defines two parameters used by the print command. You can change these parameters by editing printopt.m yourself. See Editing printopt.m for more information.

The parameters are:

The print command obtains the settings in printopt.m using the command

This table shows the default values for pcmd and dev on each platform.

Platform
pcmd default values
dev default values
Microsoft Windows
Microsoft Windows (with no default printer specified)
COPY /B %s default_printer
COPY /B %s LPT1:
-dwin
Silicon Graphics
lp
-dps2
UNIX (except Silicon Graphics)
lpr -r -s
-dps2

The value entered for pcmd must be understood by your operating system.

The dev value can be set to any driver supported by MATLAB. The default Windows driver, -dwin, specifies black-and-white printing through the Windows Print Manager. The default UNIX driver,-dps2, produces black and white Level 2 PostScript. For the full list values for dev, see the "Drivers" section of the print reference page.

Editing printopt.m

You or your system manager can edit the file printopt.m, which is located in the toolbox\local directory. If you are working on a multiuser system, you can make a copy of printopt.m and place it on your search path ahead of the MATLAB version. To edit printopt.m, enter the command

This command opens printopt.m in your text editor. Scroll down about 40 lines until you come to this comment line.

Find the line below this that sets dev. Replace the text string with an appropriate value. For example, to set the default device type to HP LaserJet III, modify the line to read,

For the full list values for dev, see the "Drivers" section of the print reference page.


 Using the Print Dialog Box Types of Printer Drivers