Signal Conversion

Convert signal to new type without altering signal values

Library

Signal Attributes

Description

The Signal Conversion block converts a signal from one type to another. Use the Output parameter to select the type of conversion to perform.

Data Type Support

The Signal Conversion block accepts signals of the following data types:

  • Scalar

  • Floating point

  • Built-in integer

  • Fixed point

  • Boolean

  • Enumerated

  • Virtual and nonvirtual bus signals

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

For more information about data types, see Data Types Supported by Simulink in the Simulink® documentation.

Parameters and Dialog Box

Output

Specify the type of conversion to perform. The type of conversion that you use depends on your modeling goal.

Modeling GoalOutput Option

Reduce generated code for a muxed signal.

For an example involving Simulink Coder™ software, see Reusable Code and Referenced Models.

Signal copy

Connect a block with a constant sample time to an output port of an enabled subsystem.

For more information, see Use Blocks with Constant Sample Times in Enabled Subsystems.

Signal copy

Pass a bus signal, or array of buses signal, whose components have different data types to a nonvirtual Inport block in an atomic subsystem that has direct feedthrough.

For more information, see Composite Signals.

Signal copy

Save memory by converting a nonvirtual bus to a virtual bus.

Virtual bus

Pass a virtual bus signal to a modeling construct that requires a nonvirtual bus, such as a Model block.

Nonvirtual bus

Pass a nonvirtual bus signal from a Bus Selector block.

Nonvirtual bus

  • The Signal copy option is the default. The type of conversion that the Signal Conversion block performs using the Signal copy option depends on the type of input signal.

    Type of Input SignalConversion that the Signal Copy Option Performs
    Muxed (nonbus) signal

    Converts the muxed signal, whose elements occupy discontiguous areas of memory, to a vector signal, whose elements occupy contiguous areas of memory. The conversion allocates a contiguous area of memory for the elements of the muxed signal and copies the values from the discontiguous areas (represented by the block's input) to the contiguous areas (represented by the block's output) at each time step.

    Bus signal

    Outputs a contiguous copy of the bus signal that is the input to the Signal Conversion block.

    For an array of buses input signal, use the Signal copy option.

    In the following example, a muxed signal inputs to a Signal Conversion block that has the Output parameter set to Signal copy. The Signal Conversion block converts the input signal to a vector.

    In the following example, a nonvirtual bus signal from a Bus Creator block inputs to a Signal Conversion block that has Output set to Signal copy. The Signal Conversion block creates another contiguous copy of the input bus signal.

  • The Virtual bus option converts a nonvirtual bus to a virtual bus.

    In the following example, a Bus Creator block inputs to a Signal Conversion block that has Output set to Virtual bus. The Signal Conversion block converts the nonvirtual bus signal from the Bus Creator block to a virtual bus signal that inputs to the Bus Selector block.

  • The Nonvirtual bus option converts a virtual bus to a nonvirtual bus.

    In the following example, the Signal Conversion block converts a virtual bus signal from the first Bus Selector block to a nonvirtual bus signal that inputs to the second Bus Selector block. The Signal Conversion block has its Output parameter set to Nonvirtual bus, and specifies a bus object that matches the bus signal hierarchy of the bus that the first Bus Creator block outputs.

Data type

Specify the output data type of the nonvirtual bus that the Signal Conversion block produces.

This option is available only when you set the Output parameter to Nonvirtual bus.

The default option is Inherit: auto, which uses a rule that inherits a data type.

You must specify a Simulink.Bus object in the Data type parameter for one or both of the following blocks:

If you specify a bus object for the Signal Conversion block, but not for its upstream Bus Creator block, then use a bus object that matches the hierarchy of the bus that upstream Bus Creator block outputs.

If you specify a bus object for both the Signal Conversion block and its upstream Bus Creator block, use the same bus object for both blocks.

You can select the button to the right of the Data type parameter to open the Data Type Assistant, which helps you to set the Data type parameter.

See Specify Block Output Data Types for more information.

Exclude this block from 'Block reduction' optimization

This option is available only when you set the Output parameter to Signal copy. If the elements of the input signal occupy contiguous areas of memory, then as an optimization, Simulink software eliminates the block from the compiled model . If you select the Exclude this block from 'Block reduction' optimization check box, the optimization occurs the next time you compile the model. For more information, see Block reduction.

Characteristics

Sample Time

Inherited from the driving block

Scalar Expansion

n/a

Dimensionalized

n/a

Multidimensionalized

Yes

Zero-Crossing Detection

No

Was this topic helpful?