Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close all figures when a script is running in Matlab

Tags:

matlab

figures

Assume that a script is running in Matlab. Is there any way to close all figures? (Closing each figure individually is tedious, and since the script is running I cannot add close all to it.)

like image 233
Franck Dernoncourt Avatar asked Feb 19 '15 22:02

Franck Dernoncourt


2 Answers

I recommend to run such scripts using a command line version of matlab, including the option -noFigureWindows. If you want to run it in a full matlab UI (which is slower), use a timer object:

t = timer('TimerFcn',@(x,y)(close('all')), 'Period', 10.0);
start(t)

Don't forget to close and delete the timer after finishing your script.

like image 73
Daniel Avatar answered Sep 27 '22 23:09

Daniel


This works for me (tested in R2010b): in Matlab's command prompt, go to the menu bar, select Windows, then Close All Documents. This closes all figures, as well as editor files, while an m-file is running.

enter image description here

like image 37
Luis Mendo Avatar answered Sep 27 '22 23:09

Luis Mendo