12.07.2015 Views

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Example: findobjThe findobj comm<strong>and</strong> is used to search through the graphical hierarchyfor objects that satisfy particular property values. For example, generatea sphere, a cylinder, <strong>and</strong> a cone:subplot(131)sphereaxis equalax = axis;subplot(132)cylinderaxis equalaxis(ax)subplot(133)cylinder([1 0])axis equalaxis(ax)The three shapes are represented by three surface objects within threeaxes objects. To get the surface h<strong>and</strong>les by getting the children <strong>of</strong> thethree axes you would need to type three calls to get; one for each <strong>of</strong> theaxes:axes_h<strong>and</strong>les = get(gcf,’children’);surf_h<strong>and</strong>le(1) = get(axes_h<strong>and</strong>les(1),’children’);surf_h<strong>and</strong>le(2) = get(axes_h<strong>and</strong>les(2),’children’);surf_h<strong>and</strong>le(3) = get(axes_h<strong>and</strong>les(3),’children’);But an easier way to get the surface h<strong>and</strong>les is to use the findobjcomm<strong>and</strong>. Here we use it to find all the objects in the current figurewhose type property has the value surface:surf_h<strong>and</strong>le = findobj(gcf,’type’,’surface’);We can now work with the vector <strong>of</strong> surface h<strong>and</strong>les to alter all thesurfaces at once. Let us make them transparent:set(surf_h<strong>and</strong>le,’FaceColor’,’none’)c○ 2000 by CRC Press LLC

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!