MATLAB Creating Graphical User Interfaces

(Barry) #1

9 Examples of GUIDE UIs


The surface function plots the surface into the axes. Setting the Parent of the surface
to hgrotate puts the surface object under the control of the hgtransform that spins
the globe (see the illustration in “Orient the Globe and Graticule” on page 9-76). By
setting EdgeColor to 'none', the globe displays face colors only, with no grid lines
(which, by default, display in black). The colormap function sets the colormap for the
surface to the 64-by-3 colormap cmap defined in the code, which is appropriate for terrain
display. While you can use more colors, 64 is sufficient, given the relative coarseness of
the texture map (1-by-1 degree resolution).

Plot the Graticule

Unlike the globe grid, the graticule grid displays with no face colors and gray edge color.
(You turn the graticule grid on and off by clicking the Show grid button.) Like the
terrain map, it is a surfaceplot object; however, the mesh function creates it, rather than
the surface function, as follows:

hmesh = mesh(gx,gy,gz,'parent',hgrotate,...
'FaceColor','none','EdgeColor',[.5 .5 .5]);
set(hmesh,'Visible','off')

The state of the Show grid button is initially off, causing the graticule not to display.
Show grid toggles the mesh object's Visible property.

As mentioned earlier, enlarging the graticule by 2 percent before plotting prevents the
terrain surface from obscuring it.

Orient the Globe and Graticule

The globe and graticule rotate as if they were one object, under the control of a pair of
hgtransform objects. Within the figure, the HG objects are set up in this hierarchy.
Free download pdf