Current figure handle
The current figure is the target for graphics output. It is the figure window in which graphics commands such as plot, title, and surf draw their results. It is typically the last figure created or the last figure clicked with the mouse.
To view a list of all figure properties, execute get(gcf) or see Figure Properties.
To get the handle of the current figure without forcing the creation of a figure if one does not exist, query the CurrentFigure property on the root object.
h = get(0,'CurrentFigure')
MATLAB® returns h as an empty array if there is no current figure.
User interaction can change the current figure. To be sure you are accessing the correct figure, store the figure handle in your program code and use this handle instead of gcf.