Connection Ports in the Simscape Language

3 views (last 30 days)
demuff
demuff on 20 Mar 2015
Answered: Sabin on 13 Aug 2025
I am currently writing some code to programmatically create composite Simscape component .ssc files from existing block diagrams. I would like the process to be as automatic as possible, but have run into the following issues:
  1. How can I detect the node variable for blocks that are being used in the current model? Say I have a standard Flow Rate Sensor block from the foundation library. The block mask labels its ports as A, B, and Q, but it is not guaranteed that the labels are actually the node variables which need to be referenced in the connections section. If I were to write my own composite component from scratch (script aside), how would I know the node variables? I have not found any easy way thus far past assuming the mask labels are correct.
  2. A bigger problem is how to determine if a particular connection port is used as a conserving port (thus requiring a node declaration) or a physical signal port (thus requiring an outputs declaration). Neither the block nor port parameters seem to differentiate them in any way, yet they are handled quite differently in the ssc file.
If anyone has any idea how these items could be solved, I would greatly appreciate the advice. Thanks!

Answers (1)

Sabin
Sabin on 13 Aug 2025
This was not easy to do in 2015. Fortunately, in R2018b Simscape introduced subsystem2ssc function which can be used to convert a subsystem containing Simscape blocks into equivalent Simscape file or files.

Categories

Find more on Composite Components in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!