Page 117 - A Guide to MATLAB for Beginners and Experienced Users
P. 117
98 Chapter 6: M-Books
square statement. In general, as you refine your graphics in an M-book, you
will find it is more desirable to modify the input cells that generated them,
rather than to produce more pictures by repeating the command with new
options. So when adding things such as xlabel, ylabel, legend, title,
etc., it is usually best to just add them to the graphics input cell and reevalu-
ate. As a result, input cells generating graphics in M-books often end up being
several lines long.
In instances where you really do want to generate a new picture, then you
need to think about whether you want to have hold set to on or off. This
feature works exactly as in a Command Window — if hold is set to on, what-
ever graphic results from your next command will be combined with whatever
last graphic you produced; and if hold is off, then previous graphics will not
influence any graphic you generate.
Since there are no separate graphics windows, the command figure is of
limited use in M-books; you probably should not use it. If you do, it will produce
a blank graph. Similarly, there are other graphics commands that are not so
suitable for use in M-books, for example close.
There is one exception to this rule: Sometimes you might want to use a
figure window along withan M-book, for example to rotate a plot withthe
mouse. If you type figure from the Command Window to open a figure
window, then subsequent graphics from the M-book will appear
simultaneously in the figure window and in the M-book itself.
Finally, we note the button Toggle Graph Output for Cell, the only button
on the Notebook menu not previously described. If you select a cell contain-
ing a graphics command and click on this button, no graphical output will
result from the evaluation of this command. This can be useful when used
in conjunction with hold on if you want to produce a single graphic using
multiple command lines.
More Hints for Effective Use of M-Books
If an interactive mode and/or attractive output beyond what you can achieve
with M-files and diary files is your goal, then you should get used to working in
the M-book interface rather than in a Command Window. Even experienced
MATLAB users will find that in time they will get use to the environment.
Here are a few more hints to smooth your transition.
In Chapter 3 we outlined some strategies for effective use of M-files, es-
pecially in the realm of debugging. Many of the techniques we described are