Main Content

gobjects

Initialize array for graphics objects

Description

H = gobjects(n) returns an n-by-n graphics object array. Use the gobjects function instead of the ones or zeros functions to preallocate an array to store graphics objects.

H = gobjects(s1,...,sn) returns an s1-by-...-by-sn graphics object array, where the list of integers s1,...,sn defines the dimensions of the array. For example, gobjects(2,3) returns a 2-by-3 array.

example

H = gobjects(v) returns a graphics object array where the elements of the row vector, v, define the dimensions of the array. For example, gobjects([2,3,4]) returns a 2-by-3-by-4 array.

example

H = gobjects returns a 1-by-1 graphics object array.

H = gobjects(0) returns an empty graphics object array.

example

Examples

collapse all

Preallocate a 4-by-1 array to store graphics handles.

H = gobjects(4,1)
H = 
  4x1 GraphicsPlaceholder array:

  GraphicsPlaceholder
  GraphicsPlaceholder
  GraphicsPlaceholder
  GraphicsPlaceholder

Create an array to store graphics handles using the size of an existing array.

Define A as a 3-by-4 array.

A = [1,2,3,2; 4,5,6,6; 7,8,9,7];

Create an array of graphics handles using the size of A.

v = size(A);
H = gobjects(v);

The dimensions of the graphics handle array are the same as the dimensions of A.

isequal(size(H),size(A))
ans = logical
   1

Use the gobjects function to return an empty array.

H = gobjects(0)
H = 
  0x0 empty GraphicsPlaceholder array.

Input Arguments

collapse all

Size of the object array, specified as an integer value. Negative integers are treated as 0. The array has dimensions n-by-n.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Size of each array dimension, specified as a list of two or more integer values. Negative integers are treated as 0.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Size of each array dimension, specified as a row vector of integer values. Negative integers are treated as 0.

Example: [2,4,6,7]

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Define an empty array by specifying one or more dimension equal to 0

Output Arguments

collapse all

Initialized graphics object array of type GraphicsPlaceholder. Use this array to contain any type of graphics object.

Version History

Introduced in R2013a

See Also

Go to top of page