PLS_Toolbox Documentation: gselect< gscaler helppls >

gselect

Purpose

Selects subset of plotted line object points using a variety of interactive graphical modes.

Synopsis

 

selected = gselect(mode,TargetHandle,modalwindow)

[x,y]    = gselect(mode,TargetHandle,modalwindow)

Description

GSELECT is a general utility which allows user-selection of plotted objects (points, line segments, areas of images, etc.). A variety of selection modes can be used on various types of plots. Each mode allows the user to select an area or range of the current axes. After selection is complete, the function returns a cell array that contains one cell for each line or image object on the axes. These cells contain a binary (true/false) array representing the selected points of each object.

The input mode is a string representing the selection mode. This governs how GSELECT selects objects in a figure. mode can be one of the following strings {default = 'rbbox'}:

            'x':   select a single x-axis position (snaps-to line x-data),

            'y':   select a single y-axis position (snaps-to line y-data),

           'xs':   select range of x-axis positions (snaps-to line x-data),

           'ys':   select range of y-axis positions (snaps-to line y-data),

        'rbbox':   select points inside a standard rubber-band box {default },

      'polygon':   select points inside a polygon (user selects corners),

        'paint':   drag a broad line across points for selection,

      'nearest':   select single nearest point,

          'all':   selects all points (no user interaction required), and

         'none':   selects no points (no user interaction required).

Optional input TargetHandle is the handle or handles of objects to test for selection. The default is all lines, patches, surfaces, and images. The optional input modalwindow is a flag which, when set to 1, indicates that the figure should be made "modal" during selection (a modal window can not be inturrupted by other actions) {default = 0}.

The output is a cell array selection. Each cell in selection will be equal in length to the data used to create the corresponding object. For example, if a vector containing 30 points was plotted, the resulting cell will be a vector of 30 binary values. Each selected point on that object will be represented by a value of 1 (one) in the cell, unselected objects by a value of 0 (zero).

If two outputs [x,y] are requested, GSELECT does not test objects for selection and simply returns the x and y points defining the selected area.

Examples

Example 1. Plot a vector of 10 random values and let the user select from these points using the standard rubber-band box.

 

plot(randn(10,3), randn(10,3), '.'); slct = gselect('rbbox')

The output will be something like:

 

slct =

    [1x10 uint8]

>> slct{1}

ans =

     0     0     0     0     1     1     0     1     0     0

>> find(slct{1})

ans =

     5     6     8

indicating that points 5, 6 and 8 were selected by the user.

Example 2. Plot a small image and let the user select a sub-range using the polygon tool.

 

imagesc(randn(6,6)); slct = gselect('polygon')

The output will be something like:

 

slct =

    [6x6 uint8]

>> slct{1}

ans =

     0     0     0     0     0     0

     0     1     0     0     0     0

     0     1     1     1     0     0

     0     1     1     1     0     0

     0     1     0     1     1     0

     0     1     0     1     0     0

indicating the "n" shaped region selected by the user.

See Also

imgselct, plotgui


< gscaler helppls >