Main Content

Animator Properties

Animator appearance and behavior

UIContextMenuproperty is not recommended. UseContextMenuinstead. For more information, seeCompatibility Considerations.

Animatorproperties control the appearance and behavior of anAnimatorobject. By changing property values, you can modify certain aspects of theAnimatorobject. You can use dot notation to refer to a particular object and property:

fp = fanimator(@(x) plot(x,sin(x),'bo')) ls = fp.Visible fp.Visible = 'off'

Frames

expand all

This property is read-only.

Range of the animation time parameter, specified as a two-element row vector. The two elements must be real values that are increasing.

This property is read-only.

Frame rate, specified as a positive value. The frame rate defines the number of frames per unit time interval of an animation object.

Interactivity

expand all

State of visibility, specified as'on'or'off', or as numeric or logical1(true) or0(false). A value of'on'is equivalent totrue, and'off'is equivalent tofalse. Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of typematlab.lang.OnOffSwitchState.

  • 'on'— Display the object.

  • 'off'——隐藏对象没有删除它。You still can access the properties of an invisible object.

Context menu, specified as aContextMenuobject. Use this property to display a context menu when you right-click the object. Create the context menu using theuicontextmenufunction.

Callbacks

expand all

Mouse-click callback, specified as one of these values:

  • Function handle.

  • Cell array containing a function handle and additional arguments.

  • Character vector that is a valid MATLAB®command or function, which is evaluated in the base workspace (not recommended).

Use this property to execute code when you click the object. If you specify this property using a function handle, then MATLAB passes two arguments to the callback function when executing the callback:

  • Clicked object — Access properties of the clicked object from within the callback function.

  • Event data — Empty argument. Replace it with the tilde character (~) in the function definition to indicate that this argument is not used.

For more information on how to use function handles to define callback functions, seeCallback Definition.

Object creation function, specified as one of these values:

  • Function handle.

  • Cell array in which the first element is a function handle. Subsequent elements in the cell array are the arguments to pass to the callback function.

  • Character vector containing a valid MATLAB expression (not recommended). MATLAB evaluates this expression in the base workspace.

For more information about specifying a callback as a function handle, cell array, or character vector, seeCallback Definition.

This property specifies a callback function to execute when MATLAB creates the object. MATLAB initializes all property values before executing theCreateFcncallback. If you do not specify theCreateFcnproperty, then MATLAB executes a default creation function.

Setting theCreateFcnproperty on an existing component has no effect.

If you specify this property as a function handle or cell array, you can access the object that is being created using the first argument of the callback function. Otherwise, use thegcbofunction to access the object.

Object deletion function, specified as one of these values:

  • Function handle.

  • Cell array in which the first element is a function handle. Subsequent elements in the cell array are the arguments to pass to the callback function.

  • Character vector containing a valid MATLAB expression (not recommended). MATLAB evaluates this expression in the base workspace.

For more information about specifying a callback as a function handle, cell array, or character vector, seeCallback Definition.

This property specifies a callback function to execute when MATLAB deletes the object. MATLAB executes theDeleteFcncallback before destroying the properties of the object. If you do not specify theDeleteFcnproperty, then MATLAB executes a default deletion function.

If you specify this property as a function handle or cell array, you can access the object that is being deleted using the first argument of the callback function. Otherwise, use thegcbofunction to access the object.

Callback Execution Control

expand all

Callback interruption, specified as'on'or'off', or as numeric or logical1(true) or0(false). A value of'on'is equivalent totrue, and'off'is equivalent tofalse. Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of typematlab.lang.OnOffSwitchState.

This property determines if a running callback can be interrupted. There are two callback states to consider:

  • Therunningcallback is the currently executing callback.

  • Theinterruptingcallback is a callback that tries to interrupt the running callback.

MATLAB determines callback interruption behavior whenever it executes a command that processes the callback queue. These commands includedrawnow,figure,uifigure,getframe,waitfor, andpause.

If the running callback does not contain one of these commands, then no interruption occurs. MATLAB first finishes executing the running callback, and later executes the interrupting callback.

If the running callback does contain one of these commands, then theInterruptibleproperty of the object that owns the running callback determines if the interruption occurs:

  • If the value ofInterruptibleis'off', then no interruption occurs. Instead, theBusyActionproperty of the object that owns the interrupting callback determines if the interrupting callback is discarded or added to the callback queue.

  • If the value ofInterruptibleis'on', then the interruption occurs. The next time MATLAB processes the callback queue, it stops the execution of the running callback and executes the interrupting callback. After the interrupting callback completes, MATLAB then resumes executing the running callback.

Note

Callback interruption and execution behave differently in these situations:

  • If the interrupting callback is aDeleteFcn,CloseRequestFcn, orSizeChangedFcncallback, then the interruption occurs regardless of theInterruptibleproperty value.

  • If the running callback is currently executing thewaitforfunction, then the interruption occurs regardless of theInterruptibleproperty value.

  • If the interrupting callback is owned by aTimerobject, then the callback executes according to schedule regardless of theInterruptibleproperty value.

Note

When an interruption occurs, MATLAB does not save the state of properties or the display. For example, the object returned by thegcaorgcfcommand might change when another callback executes.

Callback queuing, specified as'queue'or'cancel'. TheBusyActionproperty determines how MATLAB handles the execution of interrupting callbacks. There are two callback states to consider:

  • Therunningcallback is the currently executing callback.

  • Theinterruptingcallback is a callback that tries to interrupt the running callback.

TheBusyActionproperty determines callback queuing behavior only when both of these conditions are met:

  • The running callback contains a command that processes the callback queue, such asdrawnow,figure,uifigure,getframe,waitfor, orpause.

  • The value of theInterruptibleproperty of the object that owns the running callback is'off'.

Under these conditions, theBusyActionproperty of the object that owns the interrupting callback determines how MATLAB handles the interrupting callback. These are possible values of theBusyActionproperty:

  • 'queue'— Puts the interrupting callback in a queue to be processed after the running callback finishes execution.

  • 'cancel'— Does not execute the interrupting callback.

This property is read-only.

Deletion status, returned as an on/off logical value of typematlab.lang.OnOffSwitchState.

MATLAB sets theBeingDeletedproperty to'on'when theDeleteFcncallback begins execution. TheBeingDeletedproperty remains set to'on'until the component object no longer exists.

Check the value of theBeingDeletedproperty to verify that the object is not about to be deleted before querying or modifying it.

Parent/Child

expand all

指定的家长,ed as anAxesobject.

Children, returned as a graphics object. Use this property to view the property values of the graphics object.

You cannot add or remove children using theChildrenproperty. You can only setChildrento a permutation of itself.

Visibility of the object handle in theChildrenproperty of the parent, specified as one of these values:

  • 'on'— Object handle is always visible.

  • 'off'— Object handle is invisible at all times. This option is useful for preventing unintended changes to the UI by another function. Set theHandleVisibilityto'off'to temporarily hide the handle during the execution of that function.

  • 'callback'— Object handle is visible from within callbacks or functions invoked by callbacks, but not from within functions invoked from the command line. This option blocks access to the object at the command line, but permits callback functions to access it.

如果对象不是中列出Childrenproperty of the parent, then functions that obtain object handles by searching the object hierarchy or querying handle properties cannot return it. Examples of such functions include theget,findobj,gca,gcf,gco,newplot,cla,clf, andclosefunctions.

Hidden object handles are still valid. Set the rootShowHiddenHandlesproperty to'on'to list all object handles regardless of theirHandleVisibilityproperty setting.

Identifier

expand all

This property is read-only.

Type of graphics object, returned as'animator'. Use this property to find all objects of a given type within a plotting hierarchy. For example, you can use thefindobjfunction to find graphics objects of type'animator'.

Object identifier, specified as a character vector or string scalar. You can specify a uniqueTagvalue to serve as an identifier for an object. When you need access to the object elsewhere in your code, you can use thefindobjfunction to search for the object based on theTagvalue.

User data, specified as any MATLAB array. For example, you can specify a scalar, vector, matrix, cell array, character array, table, or structure. Use this property to store arbitrary data on an object.

If you are working in App Designer, create public or private properties in the app to share data instead of using theUserDataproperty. For more information, seeShare Data Within App Designer Apps.

Version History

Introduced in R2019a

expand all

Not recommended starting in R2020a