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.

MarkerEdgeColor = auto(<strong>and</strong> so on)In the example above we used get to get the h<strong>and</strong>le <strong>of</strong> the line afterwe created it. If you know that you will want to modify an object’sproperties, you can assign its h<strong>and</strong>le at creation time by using an outputvariable. Our example then becomes:h = plot(t,sin(t));set(h,’Marker’,’o’)This technique works for all <strong>of</strong> the plotting comm<strong>and</strong>s, surf, semilogx,image, <strong>and</strong> so on.Another way to set object properties is to call a creation functionwith a list <strong>of</strong> property/value pairs at the end <strong>of</strong> the argument list. Eachkind <strong>of</strong> graphical object (except the Root object) can be created bytyping a comm<strong>and</strong> with the same name as the object. For example, letus create a set <strong>of</strong> axes suitable for plotting range–depth data:axes(’Position’,[.1.5 .8 .08],’TickDir’,’out’,...’YDir’,’reverse’,’xax’,’top’)This call to the axes function has specified the position property so thatwe get a short, wide set <strong>of</strong> axes; the direction <strong>of</strong> the tick marks so thatthey stick out <strong>of</strong> the box instead <strong>of</strong> into it; the direction <strong>of</strong> the y-axisis reversed, <strong>and</strong> the location <strong>of</strong> the x-axis is on top. The capitalisation<strong>of</strong> the property names is not important. The name <strong>of</strong> a property neednot be spelled out in full: you can abbreviate it to the shortest uniquename. In the above call to axes, for example, the xax property is theXAxisLocation.If you are unsure <strong>of</strong> the allowed values for a property, you can get alist <strong>of</strong> them by typing set without actually setting a value. For example,suppose you know there is an Axes property called XAxisLocation butyou do not know whether to type ’above’, ’top’, or’up’ to get thex-axis drawn at the top. The solution is to type:>> set(gca,’XAxisLocation’)[ top | {bottom} ]The allowed values for the XAxisLocation property are top <strong>and</strong> bottom.Curly brackets are put around the default setting. If you type setc○ 2000 by CRC Press LLC

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

Saved successfully!

Ooh no, something went wrong!