How Structure Inputs and Outputs Interface with Bus Signals

Buses in a Simulink® model appear inside the MATLAB Function block as structures; structure outputs from the MATLAB Function block appear as buses in Simulink models. When you create structure inputs, the MATLAB Function block determines the type, size, and complexity of the structure from the input signal. When you create structure outputs, you must define their type, size, and complexity in the MATLAB® function.

You connect structure inputs and outputs from MATLAB Function blocks to any bus signal, including:

  • Blocks that output bus signals — such as Bus Creator blocks

  • Blocks that accept bus signals as input — such as Bus Selector and Gain blocks

  • S-Function blocks

  • Other MATLAB Function blocks

You can use global bus type data in Data Store Memory blocks with MATLAB Function blocks. For more information on using buses and Data Store Memory, see Data Stores with Buses and Arrays of Buses.

Working with Virtual and Nonvirtual Buses

MATLAB Function blocks supports nonvirtual buses only (see Virtual and Nonvirtual Buses). When models that contain MATLAB Function block inputs and outputs are built, hidden converter blocks are used to convert bus signals for code generation from MATLAB, as follows:

  • Converts incoming virtual bus signals to nonvirtual buses for inputs to structures in MATLAB Function blocks

  • Converts outgoing nonvirtual bus signals from MATLAB Function blocks to virtual bus signals

Was this topic helpful?