Main Content

Simulink.ConnectionBus

Specify properties of physical connection buses

Description

A Simulink.ConnectionBus object is a data type that, when used with Simulink.ConnectionElement objects, lets you design rigid interface specifications for Simscape™ conserving connections. When you apply such rigid specification to a Simscape Bus or Connection Port block, the block ports become typed by the interface and do not accept connections to a different domain type.

A ConnectionBus object specifies the architectural properties of an interface, such as element names, hierarchy, and domain types. A ConnectionBus object is similar to a cable connector. The connector defines all the pins and their configuration and controls what types of wires can be connected to it. Similarly, a ConnectionBus object defines the configuration and domain types of the ports of the associated Simscape Bus or Connection Port blocks.

ConnectionBus objects contain Simulink.ConnectionElement objects. Each ConnectionElement object specifies the properties of a port in a connection bus, such as its name and domain type. To create nested connection buses, specify a ConnectionElement on the parent bus and set its type as the child ConnectionBus object.

To create and modify ConnectionBus objects in the base workspace or a data dictionary, you can use the Bus Editor, the Model Explorer, or MATLAB® commands. You cannot store ConnectionBus objects in model workspaces.

To simulate a model containing blocks that use a ConnectionBus object, that ConnectionBus object must be in the base workspace or in a data dictionary. You save and load ConnectionBus objects similar to Simulink.Bus objects. For more information, see Determine How to Manage Simulink.Bus Objects.

To apply an existing connection bus specification to a Simscape Bus or Connection Port block, use the Connection type parameter and select the bus name from the drop-down list.

Creation

Description

example

name = Simulink.ConnectionBus returns a ConnectionBus object with default property values. The name of the ConnectionBus object is the name of the MATLAB variable to which you assign the ConnectionBus object.

Properties

expand all

Connection bus description, specified as a character vector. Use the description to document information about the ConnectionBus object, such as the application it is used for or domain types of its ports. This information does not affect Simulink® processing.

Data Types: char | string

Elements of connection bus, specified as an array of Simulink.ConnectionElement objects. Each ConnectionElement object defines the properties of a conserving connection within the bus, such as its name and domain type. For more information, see Simulink.ConnectionElement.

Examples

collapse all

Define a rigid interface with one mechanical translational and one electrical port by creating a ConnectionBus object containing a two-element array of ConnectionElement objects. Array indexing lets you create and access multiple elements in an array. Dot notation lets you access property values.

Create a ConnectionBus object called MechElec:

MechElec = Simulink.ConnectionBus
     
 MechElec = 

  ConnectionBus with properties:

    Description: ''
       Elements: [0×0 Simulink.ConnectionElement]

By default, the connection bus has no description and an empty array of connection elements.

Use the dot notation to fill in the description:

MechElec.Description = 'Rigid interface with one mechanical and one electrical port'
     
 MechElec = 

  ConnectionBus with properties:

    Description: 'Rigid interface with one mechanical and one electrical port'
       Elements: [0×0 Simulink.ConnectionElement]

Create a ConnectionElement object to define the mechanical translational port:

mech = Simulink.ConnectionElement
     
 mech = 

  ConnectionElement with properties:

           Name: 'a'
           Type: 'Connection: <domain name>'
    Description: ''

This command creates a ConnectionElement object with default properties.

Change the ConnectionElement name to mech:

mech.Name = 'mech'
     
 mech = 

  ConnectionElement with properties:

           Name: 'mech'
           Type: 'Connection: <domain name>'
    Description: ''

Specify the domain type for the connection:

mech.Type = 'Connection: foundation.mechanical.translational.translational'
     
 mech = 

  ConnectionElement with properties:

           Name: 'mech'
           Type: 'Connection: foundation.mechanical.translational.translational'
    Description: ''

For a list of Foundation domain types, see Domain-Specific Line Styles (Simscape).

Optionally, fill in the port description:

mech.Description = 'Mechanical translational port'
     
 mech = 

  ConnectionElement with properties:

           Name: 'mech'
           Type: 'Connection: foundation.mechanical.translational.translational'
    Description: 'Mechanical translational port'

Similarly, create another ConnectionElement object to define the electrical port:

elec = Simulink.ConnectionElement;
elec.Name = 'elec';
elec.Type = 'Connection: foundation.electrical.electrical';
elec.Description = 'Electrical port'
 elec = 

  ConnectionElement with properties:

           Name: 'elec'
           Type: 'Connection: foundation.electrical.electrical'
    Description: 'Electrical port'

Add the two elements to the ConnectionBus object:

MechElec.Elements = [mech elec]     
 MechElec = 

  ConnectionBus with properties:

    Description: 'Rigid interface containing one mechanical and one electrical port'
       Elements: [2×1 Simulink.ConnectionElement]

You can view the created objects in the Bus Editor:

buseditor

Alternatives

To interactively create a ConnectionBus object, use the Bus Editor or the Model Explorer.

Introduced in R2021b