Create Nonvirtual Buses

Nonvirtual buses affect simulation and code generation. A block connected to a nonvirtual bus reads inputs and writes outputs by accessing copies of the individual signals in the bus. These copies are stored in the area of memory allocated to the bus.

You can use nonvirtual buses to:

  • Display and log bus signals with a Scope block.

  • Construct an array of buses.

  • Have bus data cross MATLAB Function block or Stateflow® chart boundaries.

  • Interface with external code through an S-function.

  • Package bus data as structures in generated code.

To create a nonvirtual bus, you must specify a bus object data type and that the bus is nonvirtual at a Bus Creator, In Bus Element, Out Bus Element, Inport or Outport block.

  • Set Data type to Bus: <object name>, where <object name> is the bus object name.

  • Select Output as nonvirtual bus or, for output port blocks, Output as nonvirtual bus in parent model.

You can use a bus object to specify the data type for a block without specifying that the bus is a nonvirtual bus. Bus objects are optional for virtual buses, but required for nonvirtual buses. For more information on bus objects, see Specify Bus Properties with Bus Objects.

Model ex_bus_object_tutorial_using_objects specifies nonvirtual buses, which can be identified by their line style after model compilation .

If you clear Output as nonvirtual bus for a Bus Creator block and update the diagram, the output bus becomes virtual and the line style changes to three solid lines .

Use Nonvirtual Buses with MATLAB Function Blocks

If a MATLAB Function block outputs a structure, then you need to use a bus object to define a bus output. In model ex_bus_object_matlab_func, the MATLAB Function block includes MATLAB® code that creates a structure.

To see the structure definition, double-click the MATLAB Function block .

Open the Bus Editor and expand the bus object definition that represents the structure.

To see how the bus object is used to define the bus output for the MATLAB Function block, in the MATLAB Editor, click Edit Data and then click y. The output Type is defined as the function_bus bus object.

See Also

Classes

Related Topics