Sunday, July 26, 2009

copying object

copyobj

Copy graphics objects and their descendants

Syntax

*

new_handle = copyobj(h,p)

Description

copyobj creates copies of graphics objects. The copies are identical to the original objects except the copies have different values for their Parent property and a new handle. The new parent must be appropriate for the copied object (e.g., you can copy a line object only to another axes object).

new_handle = copyobj(h,p) copies one or more graphics objects identified by h and returns the handle of the new object or a vector of handles to new objects. The new graphics objects are children of the graphics objects specified by p.

Remarks

h and p can be scalars or vectors. When both are vectors, they must be the same length and the output argument, new_handle, is a vector of the same length. In this case, new_handle(i) is a copy of h(i) with its Parent property set to p(i).

When h is a scalar and p is a vector, h is copied once to each of the parents in p. Each new_handle(i) is a copy of h with its Parent property set to p(i), and length(new_handle) equals length(p).

When h is a vector and p is a scalar, each new_handle(i) is a copy of h(i) with its Parent property set to p. The length of new_handle equals length(h).

Graphics objects are arranged as a hierarchy. Here, each graphics object is shown connected below its appropriate parent object.





Examples

Copy a surface to a new axes within a different figure.

*

h = surf(peaks);
colormap hot
figure % Create a new figure
axes % Create an axes object in the figure
new_handle = copyobj(h,gca);
colormap hot
view(3)
grid on

Note that while the surface is copied, the colormap (figure property), view, and grid (axes properties) are not copies.

No comments:

Post a Comment