Thursday, August 13, 2009

gcbf


Get handle of figure containing object whose callback is executing

Syntax

  • fig = gcbf

Description

fig = gcbf returns the handle of the figure that contains the object whose callback is currently executing. This object can be the figure itself, in which case, gcbf returns the figure's handle.

When no callback is executing, gcbf returns the empty matrix, [].

The value returned by gcbf is identical to the figure output argument returned by gcbo.


gcbo

Return the handle of the object whose callback is currently executing

Syntax

h = gcbo

[h, figure] = gcbo

Description

h = gcbo returns the handle of the graphics object whose callback is executing.

[h, figure] = gcbo returns the handle of the current callback object and the handle of the figure containing this object.

Remarks

MATLAB stores the handle of the object whose callback is executing in the root CallbackObject property. If a callback interrupts another callback, MATLAB replaces the CallbackObject value with the handle of the object whose callback is interrupting. When that callback completes, MATLAB restores the handle of the object whose callback was interrupted.

The root CallbackObject property is read-only, so its value is always valid at any time during callback execution. The root CurrentFigure property, and the figure CurrentAxes and CurrentObject properties (returned by gcf, gca, and gco respectively) are user settable, so they can change during the execution of a callback, especially if that callback is interrupted by another callback. Therefore, those functions are not reliable indicators of which object's callback is executing.

When you write callback routines for the CreateFcn and DeleteFcn of any object and the figure ResizeFcn, you must use gcbo since those callbacks do not update the root's CurrentFigure property, or the figure's CurrentObject or CurrentAxes properties; they only update the root's CallbackObject property.

When no callbacks are executing, gcbo returns [] (an empty matrix).




gcd


Greatest common divisor

Syntax

  • G = gcd(A,B)
    [G,C,D] = gcd(A,B)

Description

G = gcd(A,B) returns an array containing the greatest common divisors of the corresponding elements of integer arrays A and B. By convention, gcd(0,0) returns a value of 0; all other inputs return positive integers for G.

[G,C,D] = gcd(A,B) returns both the greatest common divisor array G, and the arrays C and D, which satisfy the equation: A(i).*C(i) + B(i).*D(i) = G(i). These are useful for solving Diophantine equations and computing elementary Hermite transformations.

Examples

The first example involves elementary Hermite transformations.

For any two integers a and b there is a 2-by-2 matrix E with integer entries and determinant = 1 (a unimodular matrix) such that:

  • E * [a;b] = [g,0],

where g is the greatest common divisor of a and b as returned by the command
[g,c,d] = gcd(a,b).

The matrix E equals:

  • c       d
    -b/g a/g

In the case where a = 2 and b = 4:

  • [g,c,d] = gcd(2,4)
    g =
    2
    c =
    1
    d =
    0

So that

  • E =
    1 0
    -2 1

In the next example, we solve for x and y in the Diophantine equation 30x + 56y = 8.

  • [g,c,d] = gcd(30,56)
    g =
    2
    c =
    -13
    d =
    7

By the definition, for scalars c and d:

  • 30(-13) + 56(7) = 2,

Multiplying through by 8/2:

  • 30(-13*4) + 56(7*4) = 8

Comparing this to the original equation, a solution can be read by inspection:

  • x = (-13*4) = -52; y = (7*4) = 28

gcf



Get current figure handle

Syntax

  • h = gcf

Description

h = gcf returns the handle of the current figure. The current figure is the figure window in which graphics commands such as plot, title, and surf draw their results. If no figure exists, MATLAB creates one and returns its handle. You can use the statement

  • get(0,'CurrentFigure')

if you do not want MATLAB to create a figure if one does not already exist.



gco



Return handle of current object

Syntax

  • h = gco
    h = gco(figure_handle)

Description

h = gco returns the handle of the current object.

h = gco(figure_handle) returns the value of the current object for the figure specified by figure_handle.

Remarks

The current object is the last object clicked on, excluding uimenus. If the mouse click did not occur over a figure child object, the figure becomes the current object. MATLAB stores the handle of the current object in the figure's CurrentObject property.

The CurrentObject of the CurrentFigure does not always indicate the object whose callback is being executed. Interruptions of callbacks by other callbacks can change the CurrentObject or even the CurrentFigure. Some callbacks, such as CreateFcn and DeleteFcn, and uimenu Callback intentionally do not update CurrentFigure or CurrentObject.

gcbo provides the only completely reliable way to retrieve the handle to the object whose callback is executing, at any point in the callback function, regardless of the type of callback or of any previous interruptions.

Examples

This statement returns the handle to the current object in figure window 2:

  • h = gco(2)




No comments:

Post a Comment