MATLAB: Am I unable to open or print an EPS file that has been exported using the -EPSC2 and -CMYK options in MATLAB 7.4 (R2007a)

MATLAB

I am creating a surface and export the file using the following option
print -depsc2 -cmyk filename.eps
The figure can be imported into Word and seen on the screen but printing the Word file causes a printer error. I get about the top 20% of the figure then an error message printed on a separate page.
%
ERROR: ERROR: syntaxerror OFFENDING COMMAND: .STACK:
I am unable to open the file with GSView either.

Best Answer

This issue is because of the greater than character (">") written to the output file as an "end of data" marker after each section/band of the image that is written to the file.
This marker is only written when using CMYK with level 2 postscript, hence the following flags, "-psc" and "-depsc" are expected to work fine, "-psc2" and "-despc2" will fail.
According to the postscript language reference, 3rd edition, section 3.13.3 (details of individual filters) the ASCIIHexEncode and ASCIIHexDecode filters use the greater than (">") character as an end of data marker. The ref manual is available here:
The output from MATLAB is valid postscript and the problem appears to be with the interpreter - in this case Ghostview - not with the MATLAB generated output.
To work around this issue, use the following:
print -depsc -cmyk filename.eps
You can also use the RGB colorspace with the -depsc2 flag.