MATLAB: Does the PRINT function mistake the networked printer for a filename on a computer running Windows

exportMATLABroutersaveasusb

I have a networked printer on a computer running Windows. If I create a figure and try to print it with the:
print -dps
command (or any variations of "-dps"), the figure does not print to the printer.
Instead, it is printed to a file in my current working directory. The name of the file is the same as the name of the TCP/IP port that the printer is connected to.

Best Answer

When printing to a networked printer on Windows using the '-dps' option or its variants, it is expected that the printer name be a network path of the form:
\\computername\printername
where "computername" and "printername" are the particular names of the computer and printer in question. If this is not the case, the printer name is interpreted as the name of a file.
To resolve this issue, first find the appropriate network path for the printer, then edit your PRINTOPT function (which controls how the printer is called) to reset your default printer to that path. To do this:
1. Open the "Printers and Faxes" section of the Windows Control panel.
a) (Windows) Start->Settings->Control Panel
b) Select the "Printers and Other Hardware" item
Note: Depending on your Windows settings, this may not be necessary.
c) Select the "Printers and Faxes" item
Find the entry for the printer in question in that list.
2. If the entry is of the form
printername on computername
where "computername" and "printername" are some particular names, then the path you want is:
\\computername\printername
and you may skip directly to step 4.
3. If this is not the case, you will need to ensure the printer is shared. This can be done by:
a) Right-clicking the printer entry
b) Choosing the "Properties" item
c) Choosing the "Sharing" tab
d) Choosing the "Share this printer" radio button
The "printername" you want is the name displayed on this tab in the "Share name" field. It is not necessarily the same as that listed in the "Printers and Faxes" area.
The appropriate "computername" is your computer's name, which can be found in the "System" section of the Windows control panel:
a) (Windows) Start->Settings->Control Panel
b) Select the "Performance and Maintenance" item
Note: Depending on your Windows settings, this may not be necessary.
c) Select the "System" item
d) Choose the "Computer Name" tab
The appropriate "computername" is listed in the "Full computer name" entry on that tab.
4. Next, edit the PRINTOPT function to change the default printer name. Type
edit printopt
at the MATLAB prompt. This will open the MATLAB editor.
5. Locate the line that says
%---> Put your own changes to the defaults here (if needed)
6. Immediately below that line, add the following:
if ispc
def_printer = '\\computername\printername';
pcmd = ['COPY /B %s "' def_printer '"'];
end
but replace "computername" and "printername" with names you found in steps (2) or (3), above.
7. Save the file and exit the editor.
This will allow you to print to that printer using the '-dps' option. Should you want to print to another printer using the '-dps' option, you will need to remove or comment-out the code from step (6).