Define the value of "gcf" in matlab

Stupid, simple question - is the gcf value in matlab always the figure number of the active figure? Ie, if I work in Figure 5, will gcf always return 5 ?

+6
source share
3 answers

GCF returns a handle to the "current digit". This is always the number of figures of the active figure. However, if you click on another shape in the meantime, that other shape will become active. Thus, if you already know which digit you are working with, because you either forced the descriptor 5 by calling figure(5) , or because you grabbed the variable descriptor by calling fh=figure; it is safer to use a handle instead of gcf when you want to change the shape to avoid the risk of inadvertently creating another shape.

In addition, if there is currently no open shape, gcf will open a new drawing.

+8
source

This is a little more complicated than the simple yes or no answer. The pen for the current metric will usually correspond to the number displayed in the upper left corner of the picture window, but this number is displayed only when the 'NumberTitle' property of the figure is set to 'on' (by default).

Another wrinkle is that the shape handle cannot be a whole. There is a property 'IntegerHandle' figure that determines whether the handle created for the figure is an integer or an irregular real number. If this property is set to 'off' , you will get descriptor values ​​that are not integers, so the first shape you open will not have descriptor 1. For example:

 >> hFigure = figure('IntegerHandle','off') %# The only window open hFigure = 173.0040 

And the number is numbered accordingly:

enter image description here

Note that when the digit number and descriptor are displayed, there is some rounding of the number. The digits window displays only 6 digits after the decimal place. It becomes obvious that you are dealing with floating point numbers when you change the format of the command window to show more decimal places:

 >> format long >> hFigure hFigure = 1.730040283203125e+002 

In this case, the displayed pattern number and the pattern pen are slightly different.

+5
source

Yes, gcf will return a handle to the currently selected or active shape. From the documentation,

H = GCF returns the handle to the current drawing. The electric current figure is a window that includes graphic commands such as PLOT, TITLE, SURF, etc.

But also remember that:

The current number is not necessarily the latest figure on the screen.

One way to make the number "current":

By clicking on the uimenus and uicontrols contained in the figure, or by clicking on the figure's drawing area, the number will become current.

Another way is to use a curly descriptor. that is, if you named the figure as h=figure; , then figure(h) will make it the current figure.

+3
source

Source: https://habr.com/ru/post/889117/


All Articles