Search code examples
matlabpublish

Publishing .fig files without having them appear on screen


I have some code that generates a number of MATLAB figures. At the end of my program I want to publish these figures in a report. I have a script, which is passed to publish(), that uses openfig() to include the figures in the document.

This causes these figures to flash up on the screen. This is particularly annoying when I am opening figures inside a loop using a combination of close and snapnow. I've tried making these figures invisible using

openfig(PathToFigure, 'new', 'invisible')

This stops the image appearing on the screen but also stops it appearing in the report.

Is there a way of including .fig files in the report without having them appear on screen?


Solution

  • Open the figure with f=openfig(PathToFigure, 'new', 'invisible'). Then move the figure off-screen by setting its Position property (perhaps to something with negative values for the left and bottom pixels), set its Visible property to on, call snapnow. Delete the figure.