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.

Simple Two-Dimensional PatchesTo define a simple patch, specify the x <strong>and</strong> y coordinates <strong>and</strong> the facecolour:2x = [0 1 1 0];y = [0 0 1 1];patch(x,y,’y’)axis([-2 2 -2 2])10−1−2−2 −1 0 1 2The colour <strong>of</strong> the edge is black by default. The patch function automaticallycloses the edge if the last vertex is not the same as the first vertex.Patches are usually defined with noncrossing boundaries, but boundariescan cross if required:1x(4) = 2; y(4) = .5;clfpatch(x,y,’y’)0.80.60.40.200 0.5 1 1.5 2(The patch comm<strong>and</strong> is a low-level comm<strong>and</strong>, which means that it generatesa patch in the current axes without first clearing the axes. Thatis the reason for the clf above.)Between patches whose boundaries cross <strong>and</strong> those whose boundariesdo not cross are the patches whose boundaries “touch”. These can beused to create patches with holes:x = [0 .5 .5 .4 .5 .6 .5 .5 1 .5];y = [0 0 .1 .2 .3.2 .1 0 0 1];clfh = patch(x,y,’y’);10.80.60.40.200 0.5 1The tell-tale line between the outer boundary <strong>and</strong> the hole can be deletedby making it either invisible or the same colour as the face:10.8set(h,’edgecolor’,’none’)0.60.400 0.5 1(The comm<strong>and</strong> set(h,’edgecolor’,’y’) achieves the same effect.)But it would be nice to leave the edge boundary drawn around theshading; you just have to plot a line with the right points:0.2c○ 2000 by CRC Press LLC

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

Saved successfully!

Ooh no, something went wrong!