Preallocate Arrays of Graphics Objects - MATLAB & Simulink (original) (raw)
Main Content
Use the gobjects function to preallocate arrays for graphics objects. You can fill in each element in the array with a graphics object handle.
Preallocate a 4-by-1 array:
Assign axes handles to the array elements:
tiledlayout(2,2) for k=1:4 h(k) = nexttile; end
gobjects
returns a GraphicsPlaceholder
array. You can replace these placeholder elements with any type of graphics object. You must usegobjects
to preallocate graphics object arrays to ensure compatibility among all graphics objects that are assigned to the array.