Page 19 -
P. 19

y2=4;
                                plot(x2,y2,'o')
                                hold off

                             The hold off turns off the hold on feature.
                             NOTES
                                1. There is no limit to the number of plot commands you can type
                                   before the hold is turned off.
                                2. An alternative method for viewing multiple points on the same
                                   graph is available: we may instead, following the entering of the
                                   values of x1, y1, x2, y2, enter:

                                plot(x1,y1,'*',x2,y2,'o')

                             This has the advantage, in MATLAB, of assigning automatically a different
                             color to each point.



                             1.3.1  Axes Commands
                             You may have noticed that MATLAB automatically adjusts the scale on a
                             graph to accommodate the coordinates of the points being plotted. The axis
                             scaling can be manually enforced by using the command axis([xmin
                             xmax ymin ymax]). Make sure that the minimum axis value is less than the
                             maximum axis value or an error will result.
                              In addition to being able to adjust the scale of a graph, you can also change
                             the aspect ratio of the graphics window. This is useful when you wish to see
                             the correct x to y scaling. For example, without this command, a circle will
                             look more like an ellipse.

                             Example 1.5
                             Plot the vertices of a square, keeping the geometric proportions unaltered.

                             Solution: Enter the following:

                                x1=-1;y1=-1;x2=1;y2=-1;x3=-1;y3=1;x4=1;y4=1;
                                plot(x1,y1,'o',x2,y2,'o',x3,y3,'o',x4,y4,'o')
                                axis([-2 2 -2 2])
                                axis square                     %square shape

                             Note that prior to the axis square command, the square looked like a rect-
                             angle. If you want to go back to the default aspect ratio, type axis normal.
                             The % symbol is used so that you can type comments in your program. Com-
                             ments following the % symbol are ignored by the MATLAB interpreter.


                             © 2001 by CRC Press LLC
   14   15   16   17   18   19   20   21   22   23   24