How do I create a JPEG file and/or a plot without opening a figure window?

2 views (last 30 days)
How do I create a JPEG file and/or a plot without opening a figure window?
I want to directly send a plot to a file. In other words, I want to create a JPEG file using the PRINT command, but I do not want a figure window to open.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This bug has been fixed in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
It is possible to create a JPEG without creating a visible figure window. However, you must create a figure to contain the graphics objects. Here is an example of the code to do so:
h = figure('visible', 'off')
surf(peaks)
print -djpeg test
close(h)
PLEASE NOTE: This method is currently not available for all image formats. In particular, it does not work for bitmaps, and may not work for other formats as well.

More Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!