Page 123 - Basics of MATLAB and Beyond
P. 123

without specifying a property you get a list of all the allowed values
                               for every available property:

                               >> set(gca)
                                       AmbientLightColor
                                       Box: [ on | {off} ]
                                       CameraPosition
                                       CameraPositionMode: [ {auto} | manual ]
                                       CameraTarget
                                       CameraTargetMode: [ {auto} | manual ]
                                       (and so on)

                               The properties for which you can choose values from among a short
                               list of alternatives will be shown. Other properties (for example, the
                               CameraPosition property above) can take on any numerical value, so a
                               list of alternatives is not shown. To get the format of such a property
                               (is the CameraPosition a scalar or a vector?) you can get its current
                               value:

                               >> get(gca,’CameraPosition’)
                               ans  =
                                   0.5000     0.5000    9.1603
                                  Some properties are common to all objects. For example, all objects
                               have a “Type” property that specifies what kind of object it is (“Axes”,
                               “Figure”, “Patch” and so on), a “Parent” property (sometimes empty),
                               a “Visible” property that determines whether you can see it or not,
                               and a “Color” property (fairly obvious). Other properties are unique
                               to a particular kind of object. For example, only line objects have a
                               “LineWidth” property, and only “Figure” objects have an “InvertHard-
                               Copy” property.
                                  Let us now consolidate these ideas with a few examples.

                               Example: Undo

                               When building a plot from the command line, it is good to have an
                               “oops” function that gets rid of the last thing you plotted. Let us start
                                                                            2
                               by plotting a labelled parabola defined by f(x)= x .


                               x = -1:.01:1;
                               f = inline(’x.^2’);
                               clf
                               plt(x,f(x))


                               We use the text command to label the parabola.




                               c   2000 by CRC Press LLC
   118   119   120   121   122   123   124   125   126   127   128