Skip to Main Content Skip to Search
Product Documentation

Selector - Select input elements from vector, matrix, or multidimensional signal

Library

Signal Routing

Description

The Selector block generates as output selected or reordered elements of an input vector, matrix, or multidimensional signal.

A Selector block accepts vector, matrix, or multidimensional signals as input. The parameter dialog box and the block's appearance change to reflect the number of dimensions of the input.

Based on the value you enter for the Number of input dimensions parameter, a table of indexing settings is displayed. Each row of the table corresponds to one of the input dimensions in Number of input dimensions. For each dimension, you define the elements of the signal to work with. Specify a vector signal as a 1-D signal and a matrix signal as a 2-D signal. When you configure the Selector block for multidimensional signal operations, the block icon changes.

For example, assume a 6-D signal with a one-based index mode. The table of the Selector block dialog changes to include one row for each dimension. Suppose that you define each dimension with the following entries:

  1. Index Option, select Select all

    • Index Option, select Starting index (dialog)

    • Index, enter 2

    • Output Size, enter 5

    • Index Option, select Index vector (dialog)

    • Index, enter [1 3 5]

    • Index Option, select Starting index (port)

    • Output Size, enter 8

  2. Index Option, select Index vector (port)

  3. Index Option, select Starting and ending indices (port)

The output will be Y=U(1:end,2:6,[1 3 5],Idx4:Idx4+7,Idx5, Idx6(1):Idx6(2)), where Idx4, Idx5, and Idx6 are the index ports for dimensions 4, 5, and 6.

You can use an array of buses as an input signal to a Selector block. For details about defining and using an array of buses, see Combining Buses into an Array of Buses.

Data Type Support

The data port of the Selector block accepts signals of any signal type and any data type that Simulink supports, including fixed-point and enumerated data types. The data port accepts mixed-type signals. The index port accepts built-in data types, but not Boolean. The elements of the output have the same type as the corresponding selected input elements.

For more information, see Data Types Supported by Simulink in the Simulink documentation.

Parameters and Dialog Box

Number of input dimensions

Enter the number of dimensions of the input signal.

Index mode

Specifies the indexing mode: One-based or Zero-based. If One-based is selected, an index of 1 specifies the first element of the input vector, 2, the second element, and so on. If Zero-based is selected, an index of 0 specifies the first element of the input vector, 1, the second element, and so on.

Index Option

Define, by dimension, how the elements of the signal are to be indexed. From the list, select:

  • Select all

    No further configuration is required. All elements are selected.

  • Index vector (dialog)

    Enables the Index column. Enter the vector of indices of the elements.

  • Index vector (port)

    No further configuration is required.

  • Starting index (dialog)

    Enables the Index and Output Size columns. Enter the starting index of the range of elements to select in the Index column and the number of elements to select in the Output Size column.

  • Starting index (port)

    Enables the Output Size column. Enter the number of elements to be selected in the Output Size column.

  • Starting and ending indices (port)

    No further configuration is required.

The Index and Output Size columns appear as needed.

Index

If the Index Option is Index vector (dialog), enter the index of each element in which you are interested.

If the Index Option is Starting index vector (dialog), enter the starting index of the range of elements to be selected.

Output Size

Enter the width (number of elements from the starting point) of the block output signal.

Input port size

Specify the width of the block input signal (-1 for inherited) — 1-D signals only.

Sample time (-1 for inherited)

Specify the time interval between samples. To inherit the sample time, set this parameter to -1. See How to Specify the Sample Time in the online documentation for more information.

    Note   For 1-D signals, the Sample time parameter is available only when Index Option is Starting index (port), Index vector (port), or Starting and ending indices (port). For all other Index Option settings, the Selector block becomes a virtual block and the Sample time parameter does not appear.

Examples

The sldemo_dblcart1 model shows how to use the Selector block.

Characteristics

Sample Time

Specified in the Sample time parameter

Dimensionalized

Yes

Multidimensionalized

Yes

Virtual

Yes, when Number of input dimensions is 1 and Index Option is Select all, Index vector (dialog), or Starting index (dialog)

For more information, see Virtual Blocks in the Simulink documentation.

Zero-Crossing Detection

No

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS