Stupid, simple question - is the value of gcf
in matlab always going to be the figure number of the active figure? I.e., if I'm working on Figure 5, will gcf
always return 5
?
GCF returns the handle of the "current figure". This is always the figure number of the active figure. However, if you click on a different figure in the meantime, that other figure will become active. Thus, if you already know what figure you're working with, because you either forced the handle to 5 by calling figure(5)
, or because you captured the handle in a variable by calling fh=figure;
it is safer that you use the handle instead of gcf
whenever you want to modify the figure to avoid risking to inadvertently making another figure active.
Also, if there is no figure currently open, gcf
will open a new figure.
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