Is it possible to disable plot/figure generation in an entire script?

This is more of a trivial request, but it would be convenient for me if there was a setting I could change before running a script that simply squelches all figure and plot creation.
Does anyone know if this type of thing exists?

1 Comment

Hi, In case you know which display functions are called, simply overload them by defing new dummy functions with same name and varargin.
e.g. for plot function:
Create a plot.m in current directory or in any custom path directory as follows:
function plot(varargin)
disp('doing nothing');
end
Ignore matlab warnings telling you you overload a Matlab built-in function (you are doing it on purpose)
When plot is called you get:
>> x=randn(1,10);
>> plot(x)
doing nothing
>>

Sign in to comment.

 Accepted Answer

A sneaky way of kind of sort of doing this is:
set(groot,'defaultFigureVisible','off')
To undo this:
set(groot,'defaultFigureVisible','on')
It means the new figures will be visible off. It kind of does what you are looking for, kind of.

6 Comments

First off, thanks for the response Doug.
I tried inserting that in the beginning of my script and it didn't seem to have any effect. I didn't get an error.. but I'm still seeing lots of plot generation.
In releases before R2014b, this would be:
set(0,'DefaultFigureVisible','on')
Nailed it.
Thanks for the strategy Doug! Thanks for tweaking it Sean!
Hi, I have a similar situation. I'm worried that that command will still compute the figures, and then not show them. Is that right?
The reasons I want to not plot my plots is because in some situations I don't want to perform the hefty computation.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!