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.

31.2 Default Object PropertiesEvery graphical object has a set <strong>of</strong> default property values, so that youare not obliged to spend time thinking about every detail <strong>of</strong> every graphicalobject you draw. For example, when you type plot(1:10) you donot necessarily want to think about how thick the line should be, wherethe tick marks should go, how long the tick marks should be, what colourthe axes should be, what matlab should do when you click on the line,etc.When matlab creates a graphical object it searches through thesuccessive ancestors (parent, gr<strong>and</strong>parent, etc.) until it either finds adefault value defined by the user or a factory-set value. For example,you could define your own default line width for a figure, in which caseall new lines drawn in any axes in that figure would have the new linewidth. Or you could set a default line width in an axes object: such adefault would affect lines drawn in that set <strong>of</strong> axes, but lines drawn inanother set <strong>of</strong> axes would have their widths set by a search through theirown, different set <strong>of</strong> ancestors.To get a list <strong>of</strong> factory-defined settings, issue the comm<strong>and</strong>get(0,’factory’). You cannot change the factory settings, but youcan change the default settings. To get a single factory-defined setting,use the get comm<strong>and</strong>, giving it the property name starting withfactory, followed by the name <strong>of</strong> the graphical object (figure, axes,etc.), followed by the name <strong>of</strong> the property. For example, the factorypaper type used for printing figures is>> get(0,’factoryfigurepapertype’)ans =usletterFactory settings are not necessarily those that will be used; they may beover-ridden by setting a default value. Default values may be changedfor your matlab installation in either the matlabrc.m file or in yourpersonal startup.m file.To get a list <strong>of</strong> default settings, issue the comm<strong>and</strong> get(H<strong>and</strong>le,’Default’), where H<strong>and</strong>le is the h<strong>and</strong>le <strong>of</strong> the object you are interestedin. Setting a default value at the Root level (H<strong>and</strong>le = 0) will affect allobjects <strong>of</strong> that type.To set a default value you use the set comm<strong>and</strong>, giving it the h<strong>and</strong>le<strong>of</strong> the object whose children (gr<strong>and</strong>children, etc.) you want affected. Youcreate a default property name by creating a three-part string:1. Start with the word Default;2. Add the name <strong>of</strong> the object you want affected (for example, Line,Surface, Text);c○ 2000 by CRC Press LLC

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

Saved successfully!

Ooh no, something went wrong!