Page 47 - A Guide to MATLAB for Beginners and Experienced Users
P. 47

28        Chapter 2: MATLAB Basics


                     be included, even if only one is changed. We’ll examine more options for ma-
                     nipulating graphs in Chapter 5.
                       To close the graphics window select File : Close from its menu bar, type
                     close in the Command Window, or kill the window the way you would close
                     any other window on your computer screen.


           Graphing with plot
                     The command plot works on vectors of numerical data. The basic syntax is
                     plot(X, Y) where X and Y are vectors of the same length. For example,
                       >>X=[123];
                       >>Y=[465];
                       >> plot(X, Y)

                     The command plot(X, Y) considers the vectors X and Y to be lists of the x
                     and y coordinates of successive points on a graphand joins the points with
                     line segments. So, in Figure 2-5, MATLAB connects (1, 4) to (2, 6) to (3, 5).

                          6

                         5.8

                         5.6


                         5.4

                         5.2

                          5

                         4.8

                         4.6


                         4.4

                         4.2

                          4
                           1     1.2   1.4   1.6    1.8    2     2.2   2.4   2.6    2.8    3
                         Figure 2-5
   42   43   44   45   46   47   48   49   50   51   52