Matlab Chapter6.pdf
Matlab Chapter6.pdf
Matlab Chapter6.pdf
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Example 1.4 The characters \ pi create the symbol π.<br />
Example 1.5<br />
≫ xlabel( ′ x = 0 : 2\pi ′ )<br />
≫ ylabel( ′ Sine of x ′ )<br />
≫ title( ′ Plot of the Sine Function’,’FontSize ′ , 12)<br />
≫ t = −pi : pi/100 : pi;<br />
≫ y = sin(t);<br />
≫ plot(t, y)<br />
≫ axis([−pi pi − 1 1])<br />
≫ xlabel( ′ −\pi ≤ t ≤ \pi ′ )<br />
≫ ylabel( ′ sin(t) ′ )<br />
≫ title(’Graph of the sine function’)<br />
≫ text(1, −1/3, ′ Notetheoddsymmetry. ′ )<br />
You can also set these options interactively. Note that the location of the text string is defined<br />
in axes units (i.e., the same units as the data).<br />
Remark 1.2 Graphs may be labeled with the following statements:<br />
≫ gtext(text)<br />
writes a string (text) in the graph window. gtext puts a cross-hair in the graph window<br />
and waits for a mouse button or keyboard key to be pressed. The cross-hair can be positioned<br />
with the mouse or the arrow keys. For example,<br />
≫ gtext(Xmarksthespot)<br />
Text may also be placed on a graph interactively with Tools click Edit Plot from the figure<br />
window.<br />
≫ text(x, y, text)<br />
writes text in the graphics window at the point specified by x and y.<br />
If x and y are vectors, the text is written at each point. If the text is an indexed list,<br />
successive points are labeled with corresponding rows of the text.<br />
≫ title(text)<br />
1.8 Figure Windows<br />
Graphing functions automatically open a new figure window if there are no figure windows<br />
already on the screen. If a figure window exists, MATLAB uses that window for graphics<br />
output. If there are multiple figure windows open, MATLAB targets the one that is designated<br />
the “current figure” (the last figure used or clicked in).<br />
To make an existing figure window the current figure, you can click the mouse while the<br />
pointer is in that window or you can type<br />
≫ figure(n)<br />
where n is the number in the figure title bar. The results of subsequent graphics commands<br />
are displayed in this window.<br />
≫ x = 0 : pi/100 : 2 ∗ pi;<br />
≫ y = sin(x);<br />
≫ y2 = sin(x − .25);<br />
≫ y3 = sin(x − .5);<br />
≫ plot(x, y)<br />
≫ plot(x, y2)<br />
≫ plot(x, y3)<br />
5