How to suppress figures?

To make the current figure not visible:

set(gcf,'visible','off')

From the MathWorks-reference:

To avoid showing figures in MATLAB you can start MATLAB using the noFigureWindows option. This option is not available on UNIX.

matlab -noFigureWindows

As an alternative you can change the default figure properties of the MATLAB root object:

set(0,'DefaultFigureVisible','off')

If you want to temporarily suppress new figures that should be accesable later in the same session you can save the figure handle:

set(0,'DefaultFigureVisible','off');

 %create invisible figure 1
 h(1)=figure;
 %create invisible figure 2 
 h(2)=figure;

 set(0,'DefaultFigureVisible','on');
 %show figure 1
 figure(1)

By the way, close all closes all currently open figures.


The other answers were not working for me on R2015b on Ubuntu, my figure window would always show up.

I am processing 100+ files and the figure window popping up prevents me from using my computer while processing the files.

Here's a workaround, launch matlab without a display:

matlab -nodesktop -nodisplay

and this will prevent figure windows from showing up. Programmatically saving the figure to a file still works.

Tags:

Matlab

Plot