1

I am working on a model generation script to automatically generate Simscape models from a library of components with varying ports. Due to the vast number of ports that need to be connected across the model, I am looking for a good way to set up which ports need to be connected to each other. The best solution I have come up with so far is to name each port with a unique tag that indicates what other ports in the system it should be connected to in the generated model. However, I am not able to obtain the name of any physical port. It is labeled on the mask, but the 'Name' parameter always comes back empty. Here's what I've tried:

h = get_param(gcb,'PortConnectivity')
port = h(1).Type %This only returns the physical port #, not custom name

h = get_param(gcb,'PortHandles')
port = get_param(h.LConn(1),'Name') %This returns an empty cell array

Not sure where to go from here. Any ideas on how to solve this? Thanks!

  • See [this answer](http://stackoverflow.com/questions/22793255/programatically-connect-two-subsystems). – am304 Jan 17 '15 at 17:49
  • 1
    Thanks for the reply, @am304. I'm able to programmatically build my model without issues, but I'm looking for a way to obtain the _labeled name_ of the physical port. The `add_line` function works as expected, but I'd like to be able to obtain the name of the port as shown on the block diagram and mask. – IntimateBadger Jan 18 '15 at 19:37
  • I don't think you can specify names for ports, only for blocks. Sorry. – am304 Jan 19 '15 at 21:52

1 Answers1

0

You can use:

name = get_param(gcb, 'Name');

to get the port name. A general tip for finding the right block property, run:

get(get_param(gcb, 'object'))

this will display all block properties and their values.

ngautier
  • 86
  • 3