Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine value of "gcf" in matlab

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?

like image 950
eykanal Avatar asked May 26 '11 13:05

eykanal


1 Answers

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.

like image 190
Jonas Avatar answered Sep 21 '22 23:09

Jonas