Main Content

Simulink.ConnectionElement

Specify properties of elements of physical connection buses

Since R2021b

Description

A Simulink.ConnectionElement object is an element of a Simulink.ConnectionBus object. It validates the properties of a physical connection port.

ConnectionElement objects exist only within the ConnectionBus object. You can specify a ConnectionBus object, but not a ConnectionElement object, as a data type.

When you simulate or update a model, Simulink® checks whether the ports connected to Simscape Bus or Connection Port blocks with rigid interface specifications match the properties of the corresponding ConnectionElement objects.

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

Creation

Description

ce = Simulink.ConnectionElement returns a ConnectionElement object with default property values.

example

Properties

expand all

Name of element, specified as a character vector. The element name must be a valid MATLAB identifier that starts with an alphabetic character or underscore (_), followed by alphanumeric characters or underscores.

Data Types: char | string

Connection type of element, specified as a Simscape Foundation domain name, a custom domain name registered in your MATLAB session, or a Simscape Multibody conserving connection type.

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

Selecting a ConnectionBus object present in the base workspace or a data dictionary lets you create nested connection buses.

If you create ConnectionElement objects interactively, by using the Type Editor or the Model Explorer, the drop-down list automatically contains all the valid domain and connection types.

Data Types: char | string

Connection element description, specified as a character vector. Use the description to document information about the ConnectionElement object, such as the domain type. This information does not affect Simulink processing.

Data Types: char | string

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 Type Editor:

typeeditor

Alternatives

To interactively create a ConnectionElement object, use the Type Editor or the Model Explorer.

Version History

Introduced in R2021b