| DSP Blockset | Search  Help Desk |
| Variable Selector | See Also |
Select a subset of elements in a vector.
Library
Elementary Functions, in Math FunctionsDescription
The Variable Selector block outputs a subset of the elements in the input vector. When the Selector mode parameter is set to Variable, the vector at the bottom input (Idx) selects the elements of the vector at the top input (In) to pass through to the output. The elements of the indexing vector can change at each sample time, but the vector must remain the same length throughout the simulation.
When the Selector mode parameter is set to Fixed, the vector specified in the Elements parameter selects the elements of the top input vector (In) to pass through to the output. The Elements parameter is tunable, so you can change the values of the indexing vector elements at any time during the simulation; however, the indexing vector must remain the same length. The Idx port is not present in Fixed mode.
For both variable and fixed indexing vectors, the selection operation is equivalent to
y = u(idx) % equivalent MATLAB codewhere
u(1) is the first input element and idx is the indexing vector. The output is therefore the same length as the indexing vector. Input elements can appear any number of times in the output, or not at all.
When an element in the indexing vector references a non-existent element of the input, the block reacts with the behavior specified by the Invalid index parameter. The following options are available:
Dialog Box

Idx port to select elements of the input at the In port. Fixed indexing uses the Elements parameter value to select elements of the input at the In port.

See Also
Permute Matrix