12.07.2015 Views

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

These comm<strong>and</strong>s change special Text objects that are associated withthe Axes object:>> yl = get(gca,’ylabel’);>> get(yl,’String’)ans =y axis>> set(yl,’Rotation’,0)>> pos = get(yl,’pos’);>> set(yl,’pos’,[0.35 3])To be friendly to the viewers <strong>of</strong> your graphs, you should always placeyour y labels horizontally. Multi-line labels can be done easily using cellarrays:>> str = {’The answer is below:’;[’It is ’ num2str(pi)]}str =’The answer is below:’’It is 3.1416’>> title(str)33 Text in GraphicsThe comm<strong>and</strong>s xlabel, ylabel, zlabel, <strong>and</strong> title are used to put textin special places around the plot. A general way to place text is to usetext comm<strong>and</strong>s:x = 0:.01:2;plt(x,humps(x))axis tight[ym,i] = max(humps(x));str = [’Maximum value: ’ ...num2str(ym)];text(x(i),ym,str)The first two inputs to text define the x <strong>and</strong> y coordinates <strong>of</strong> the text’sreference point. (The gtext comm<strong>and</strong> allows you to define the referencepoint with the mouse.) You can give a third, z-value, to the text comm<strong>and</strong>to place text on three-dimensional plots. Issuing text comm<strong>and</strong>screates Text objects, which have a great many properties (type get(h),where h is the h<strong>and</strong>le <strong>of</strong> a Text object). Often you want to change theway the text is aligned to its reference point. By default, text is horizontallyaligned such that the left-h<strong>and</strong> edge is near the reference point,<strong>and</strong> vertically aligned such that the middle <strong>of</strong> the text is near the referencepoint. The following diagrams show the effect <strong>of</strong> changing a Textc○ 2000 by CRC Press LLC

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

Saved successfully!

Ooh no, something went wrong!