Graphics Programs Reference

In-Depth Information

Example:
findobj

The
findobj
command is used to search through the graphical hierarchy

for objects that satisfy particular property values. For example, generate

a sphere, a cylinder, and a cone:

subplot(131)

sphere

axis equal

ax = axis;

subplot(132)

cylinder

axis equal

axis(ax)

subplot(133)

cylinder([1 0])

axis equal

axis(ax)

The three shapes are represented by three surface objects within three

axes objects. To get the surface handles by getting the children of the

three axes you would need to type three calls to
get
; one for each of the

axes:

axes_handles = get(gcf,'children');

surf_handle(1) = get(axes_handles(1),'children');

surf_handle(2) = get(axes_handles(2),'children');

surf_handle(3) = get(axes_handles(3),'children');

But an easier way to get the surface handles is to use the
findobj

command. Here we use it to find all the objects in the current figure

whose
type
property has the value
surface
:

surf_handle = findobj(gcf,'type','surface');

We can now work with the vector of surface handles to alter all the

surfaces at once. Let us make them transparent:

set(surf_handle,'FaceColor','none')