How to programmatically distinguish the port's domain for a simscape block? Like a connection belonging to foundation​.electrica​l.electric​al or physical signal?

25 ビュー (過去 30 日間)
Arepalli
Arepalli 2025 年 11 月 14 日 11:41
コメント済み: Arepalli 2025 年 11 月 20 日 5:33
How to programmatically distinguish the port's domain for a simscape block? Like a connection belonging to foundation.electrical.electrical or physical signal?
I am trying to automate connections between simscape custom blocks, the custom library is old and hard to change now. So for explaining the situation, consider the below example, a simple voltage sensor and code
LConn1 => + (node and bidirectional)
RConn1 => V (Physical Signal, unidirectional)
RConn2 => - (node and bidirectional)
So to automate the connections, add_line, RConn and LConn properties are used:
SourceConn = PortDetails.RConn(x)
add_line(Model_Name, SourceConn,... are the commands used.
But to automate, the distinction between RConn1 and RConn2 is needed, so a if-block can be used in code, that can allow add_line command to connect nodes to nodes only and wont try to
  1. Connect a physical signal port (V) to a node and stop execution.
  2. Connect a physical signal port (V) to another physical signal port (which could be on other block's input side ... I tried "try-catch-end" but failed due to this scenario).
So kindly let me know if there are anyways/commands/or a work around way to extract information about Simscape ports by which such automation is possible.
Thankyou.

回答 (1 件)

Yifeng Tang
Yifeng Tang 2025 年 11 月 19 日 19:45
ports = simscape.connectionPortProperties(gcb)
gcb here is pointing to a Pipe (TL) block, and I get
ports =
1×3 ConnectionPortProperties array with properties:
Name
Label
Type
and I can query into ports as
>> ports(1)
ans =
ConnectionPortProperties with properties:
Name: "A"
Label: "A"
Type: Domain (foundation.thermal_liquid.thermal_liquid)
The last line of output sounds like what you are looking for :)
  2 件のコメント
Yifeng Tang
Yifeng Tang 2025 年 11 月 19 日 19:46
Caveat: this function is only available in R2025a or newer.
Arepalli
Arepalli 2025 年 11 月 20 日 5:33
Thankyou @Yifeng Tang, for your response, but currently our team is using 2022b. If there are any other way to extract information about Simscape ports, Kindly let me know. And if there is anyway to get a port's details like it's can be a
  1. Physical Signal port or energy signal port
  2. Unidirectional or Bidirectinal ports
even the above differences can help us in meeting our requirement.
Thankyou.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSimscape についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by