Multi-Port Switch (Simulink Reference)

Simulink Reference
Multi-Port Switch

Choose between multiple block inputs

Library

Simulink Signal Routing and Fixed-Point Blockset Select

Description

The Multi-Port Switch block chooses between a number of inputs. The first (top) input is called the control input, while the rest of the inputs are called data inputs. The value of the control input determines which data input is passed through to the output port.

If the control input is an integer value, then the specified data input is passed through to the output. For example, suppose the Use zero-based indexing parameter is not selected. If the control input is 1, then the first data input is passed through to the output. If the control input is 2, then the second data input is passed through to the output, and so on. If the control input is not an integer value, the block first truncates the value to an integer by rounding to floor. If the truncated control input is less than 1 or greater than the number of input ports, an out-of-bounds error is returned.

You specify the number of data inputs with the Number of input ports parameter. The data inputs can be scalar or vector. The block output is determined by these rules:

  • If you specify only one data input and that input is a vector, the block behaves as an "index selector," and not as a multi-port switch. The block output is the vector element that corresponds to the value of the control input.
  • If you specify more than one data input, the block behaves like a multi-port switch. The block output is the data input that corresponds to the value of the control input. If at least one of the data inputs is a vector, the block output is a vector. Any scalar inputs are expanded to vectors.
  • If the inputs are scalar, the output is a scalar.

When the Show additional parameters check box is selected, some of the parameters that become visible are common to many blocks. For a detailed description of these parameters, refer to Block Parameters in the Fixed-Point Blockset documentation.

The Index Vector block, also in the Fixed-Point Blockset Select library, is another implementation of the Multi-Port Switch block that has different default parameter settings.

Data type support

The control input of a Multi-Port Switch block can be a real-valued signal of any data type, including fixed-point data types, except int64 and uint64. The data inputs can be of any complexity and data type, including fixed-point data types, except int64 and uint64.

Parameters and Dialog Box

Number of input ports Specify the number of data inputs to the block. Show additional parameters If selected, additional parameters specific to implementation of the block become visible as shown.

Use zero based indexing If selected, the block uses zero-based indexing. Otherwise, the block uses one-based indexing. Require all data port inputs to have same data type Select to require all data port inputs to have the same data type. Output data type mode You can choose to inherit the output data type and scaling by backpropagation or by an internal rule. The internal rule causes the output of the block to have the same data type and scaling as the input with the larger positive range. Round integer calculations toward Select the rounding mode for the fixed-point output. Saturate on integer overflow If selected, overflows saturate.

Characteristics

Dimensionalized Yes
Direct Feedthrough Yes
Sample Time Inherited from driving blocks
Scalar Expansion Yes
Zero Crossing No

Model InfoMux

Từ khóa » How To Use Switch Block In Simulink