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?
Stupid, simple question – is the value of gcf in matlab always going to
Share
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 callingfh=figure;it is safer that you use the handle instead ofgcfwhenever you want to modify the figure to avoid risking to inadvertently making another figure active.Also, if there is no figure currently open,
gcfwill open a new figure.