gobjects

Initialize array for graphics objects

Syntax

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

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.

example

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.

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

example

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

Examples

expand all

Specify Array Dimensions

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

H = gobjects(4,1)
H = 

  4x1 GraphicsPlaceholder array:

  GraphicsPlaceholder
  GraphicsPlaceholder
  GraphicsPlaceholder
  GraphicsPlaceholder

Specify 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

Return Empty Handle Array

Use the gobjects function to return an empty array.

H = gobjects(0)
H = 

  0x0 empty GraphicsPlaceholder array.

Input Arguments

expand all

n — defines n-by-n arrayinteger value

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

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

0 — Define an empty arrayone or more dimensions equal to 0

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

Output Arguments

expand all

H — Initialized graphics object arraygraphics object array of specified size

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

More About

Was this topic helpful?