Graphics Programs Reference
In-Depth Information
Chapter 2
MATLABBasics
Inthischapter,youwillstartlearninghowtouseMATLABtodomathematics.
You should read this chapter at your computer, with MATLAB running. Try
the commands in a MATLAB Command Window as you go along. Feel free to
experiment with variants of the examples we present; the best way to find out
how MATLAB responds to a command is to try it.
For further practice, you can work the problems in Practice Set A .The
Glossary contains a synopsis of many MATLABoperators, constants,
functions, commands, and programming instructions.
Input and Output
You input commands to MATLAB in the MATLAB Command Window. MAT-
LAB returns output in two ways: Typically, text or numerical output is re-
turned in the same Command Window, but graphical output appears in a
separate graphics window. A sample screen, with both a MATLAB Desktop
and a graphics window, labeled Figure No. 1, is shown in Figure 2-1.
To generate this screen on your computer, first type 1/2 + 1/3 . Then type
ezplot('xˆ3 - x') .
While MATLAB is working, it may display a “wait” symbol — for example,
an hourglass appears on many operating systems. Or it may give no visual
evidence until it is finished with its calculation.
Arithmetic
As we have just seen, you can use MATLAB to do arithmetic as you would a
calculator. You can use “ + ” to add, “ - ” to subtract, “ * ” to multiply, “ / ” to divide,
8
Search WWH ::




Custom Search