How to close mutiple uifigure using command

255 visualizaciones (últimos 30 días)
bo peng
bo peng el 14 de Oct. de 2020
Comentada: Voss el 4 de Abr. de 2024 a las 4:47
I run fig = uifigure many time in Matlab,so I genetared lots of uifigure ,I want to close all uifigure with one line of command.Do you know what command I should enter in Matlab.Thank you very much

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 14 de Oct. de 2020
Run this
all_fig = findall(0, 'type', 'figure');
close(all_fig)
  6 comentarios
Yang Liu
Yang Liu el 10 de Nov. de 2023
Thank you, but don't take my wife. Your codes works for me, just a quick question:
What does the 0 represent? I try to figure out with help findall, and find nothing helpful...
Thanks, and take my wife now.
Voss
Voss el 4 de Abr. de 2024 a las 4:47
0 is the graphics root object, which is also returned by the groot function, so you could do findall(groot,_)

Iniciar sesión para comentar.

Más respuestas (2)

Adam Danz
Adam Danz el 14 de Oct. de 2020
Editada: Adam Danz el 14 de Oct. de 2020
Just to add another approach,
Set HandleVisibility to on when you create the UIFigures. That way their handles will be visible to gcf() , close all, etc....
uifigure('HandleVisibility', 'on')
  5 comentarios
Adam Danz
Adam Danz el 29 de Dic. de 2021
@Jan Kudlacek, you can use Ameer Hamza's solution below.
Yang Liu
Yang Liu el 10 de Nov. de 2023
I don't konw why but this doesn't work for me... weird...

Iniciar sesión para comentar.


Bjorn Gustavsson
Bjorn Gustavsson el 14 de Oct. de 2020
If you want to keep some figures you can close a subset of them if you keep the figure-handles in an array. If you modify your creation to something like this for all call to uifigure:
if ~exist('uifig')
uifig = uifigure;
else
uifig(end+1) = uifigure;
end
if ~exist('uifig')
uifig = uifigure;
else
uifig(end+1) = uifigure;
end
% ...etc
% then you can close some suitable set of them, or all of them
% closing all:
close([uifig]),clear uifig
% closing some:
close([uifig([1 3])]),uifig([1 3]) = [];
HTH

Categorías

Más información sobre Develop uifigure-Based Apps en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by