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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With