Main Content

simscape.connectionPortProperties

Get information about names, labels, and connection types of physical modeling ports

Since R2025a

Description

ConnectionPortProperties objects contain properties corresponding to the names, labels, and connection types of physical modeling ports of a block or a subsystem. All properties are read-only. Each ConnectionPortProperties object corresponds to a single physical modeling port. You can use the ConnectionPortProperties object to find out the port name corresponding to a port label on the model canvas, and then use this name to add programmatic connections between ports by using the simscape.addConnection function.

Creation

The simscape.connectionPortProperties function (described here) returns a vector of ConnectionPortProperties objects for the physical ports of a block. To get information about the name, label, and connection type of a particular block port, index into the vector.

Description

ports = simscape.connectionPortProperties(block) returns a vector of ConnectionPortProperties objects for the physical ports of the block, block. Each element of the vector corresponds to a single port.

example

Input Arguments

expand all

Block or subsystem name, specified as a handle or a full path to a block or subsystem in the model.

Data Types: double | char | string

Output Arguments

expand all

Names, labels, and connection types of block ports, returned as a vector of ConnectionPortProperties objects. Each element of the vector corresponds to a single port. To get information about the name, label, and connection type of a particular block port, index into the vector.

Properties

expand all

Name of the block port, specified as a character vector or a string scalar. Use this name when adding programmatic connections with the simscape.addConnection function.

Port label on the model canvas, specified as a character vector or a string scalar. For masked blocks, this property is a missing string, due to a limitation.

Object of type simscape.connection.ConnectionType that specifies details about the interface type of the port.

Examples

collapse all

Open the Permanent Magnet DC Motor example model.

openExample('simscape/PermanentMagnetDCMotorExample')

Open the DC Motor subsystem.

Model diagram of the DC Motor subsystem

Get information about the ports of the Rotational Electromechanical Converter block:

 ports = simscape.connectionPortProperties("PermanentMagnetDCMotor/DC Motor/Rotational Electromechanical Converter")
ports = 

  1×4 ConnectionPortProperties array with properties:

    Name
    Label
    Type

To view information about all the ports of the block, double-click the ports variable in the workspace.

Port properties of all the block ports

To get information about a particular port, index into the ports vector, for example:

port4 = ports(4)
port4 = 

  ConnectionPortProperties with properties:

     Name: "p"
    Label: "+"
     Type: Domain (foundation.electrical.electrical)

Therefore, to connect the Rotational Electromechanical Converter block port labeled + to an electrical port of another block by using the simscape.addConnection function, use the port name p.

Version History

Introduced in R2025a