Main Content

Manual Switch

Switch between two inputs

  • Manual Switch block

Libraries:
Simulink / Signal Routing

Description

The Manual Switch block is a toggle switch that selects one of its two inputs to pass through to the output. To toggle between inputs, double-click the block. You control the signal flow by setting the switch before you start the simulation or by changing the switch while the simulation is executing. The Manual Switch block retains its current state when you save the model.

To programmatically toggle the switch, set the set_param sw property to '0' or '1'. For example, to connect the second input to the output:

set_param(gcb,'sw','0')

To connect the first input to the output:

set_param(gcb,'sw','1')

Note

Double-clicking the Manual Switch block does not open the block dialog box. Instead, it toggles the input choice.

Ports

Input

expand all

First of two inputs to the Manual Switch block. The block propagates the selected input to the output. To select the input signal, toggle the switch by double-clicking the block.

Data Types: single | double | half | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point | enumerated | bus

Second of two inputs to the Manual Switch block. The block propagates the selected input to the output. To select the input signal, toggle the switch by double-clicking the block.

Data Types: single | double | half | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point | enumerated | bus

Output

expand all

Output signal propagated from either the first or second input signal.

Data Types: single | double | half | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point | enumerated | bus

Parameters

expand all

To view the block parameters, right-click the block and select Block Parameters (ManualSwitch).

Select this check box to allow inputs with different sizes and propagate the selected input signal size to the output signal. If you clear the box, the block expands scalar inputs to have the same dimensions as nonscalar inputs. See Scalar Expansion of Inputs and Parameters.

Programmatic Use

Parameter: varsize
Type: character vector
Value: 'on' | 'off'
Default: 'off'

Specify the time interval between samples. To inherit the sample time, set this parameter to -1. For more information, see Specify Sample Time.

Dependencies

This parameter is visible only if you set it to a value other than -1. To learn more, see Blocks for Which Sample Time Is Not Recommended.

Programmatic Use

Block Parameter: SampleTime
Type: string scalar or character vector
Default: "-1"

Block Characteristics

Data Types

Boolean | bus | double | enumerated | fixed point | half | integer | single | string

Direct Feedthrough

yes

Multidimensional Signals

yes

Variable-Size Signals

yes

Zero-Crossing Detection

no

Extended Capabilities

Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™.

Version History

Introduced before R2006a