Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if a figure is opened and how to close it?

Tags:

matlab

My m-file opens figures depending on parameters. Sometimes is one figure, sometimes it opens 2 figures.

If the user call the function, the figures appear. If he calls the function again, with other parameters, I'm clearing figures with clf before the new plots.

If the second call is set to draw only one figure, the second one (opened by the previous call) remain gray (because of the clf).

Is there any way to check if it is opened and close it?

like image 614
Andrea Ambu Avatar asked Jan 22 '09 21:01

Andrea Ambu


1 Answers

close all

Will close all open figures.

You can use findobj() to find objects that may exist by specifying search parameters. For example:

figure('name','banana')

Creates a figure with the name banana.

close(findobj('type','figure','name','orange'))

Does nothing because there are no figures open with the name orange.

close(findobj('type','figure','name','banana'))

Closes the figure.

You can specify search parameters to meet your needs.

like image 98
KennyMorton Avatar answered Nov 08 '22 10:11

KennyMorton