Accelerating the pace of engineering and science

Documentation Center

• Trial Software

gobjects

Create array of graphics handles

Syntax

• H = gobjects
• H = gobjects(0) example

Description

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

example

H = gobjects(s1,...,sn) returns an s1-by-...-by-sn array of graphics handles, 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 an array of graphics handles 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.

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

example

H = gobjects(0) returns empty.

Examples

expand all

Specifying Array Dimensions

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

H = gobjects(4,1);

You can assign axes handles to the array elements.

for k = 1:4
H(k) = subplot(2,2,k);
end

Specifying Array Dimensions with Size of Existing Array

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 =

1

Returning Empty Handle Array

Use the gobjects function to return an empty array.

H = gobjects(0)
H =

[]

Input Arguments

expand all

n — Size of square matrixinteger value

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

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

s1,...,sn — Size of each array dimensiontwo or more integer values

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

v — Size of each array dimensionrow vector of integer values

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