How can I obtain the port types of destination ports connected an output port of any Simulink block, from the command line?

43 views (last 30 days)
In the attached Simulink model Test, I would like to query the port types that the inport block is connected to. I use the following code sample to determine this:
ports = get_param('test/In1', 'PortConnectivity')
ports(1)
I get the following result:
ans =
Type: '1'
Position: [155 55]
SrcBlock: []
SrcPort: []
DstBlock: [1x6 double]
DstPort: [0 1 3 2 1 0]
As it can be seen, DstPort is a vector of numbers and I do not know what is the relation between those numbers and the 'trigger', 'enable' and 'ifaction' ports.
I would like to know if there is a way to map those numbers to the corresponding 'trigger', 'enable' and 'ifaction' ports?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The difficulty with using the 'PortConnectivity' property of the inport block is that it does not list the port handles to which the inport block's output is connected to, but rather it lists the destination block handles, and port numbers. The easiest way to find out the port information of the destination ports is to use signal line information as below:
%get the porthandles of ports for the inport block
a = get_param('test/In1','PortHandles');
%get the signal line associated with the output port of the inport
line = get_param(a.Outport,'Line');
%get the destination port handles for the signal
dstport = get_param(line, 'Dstporthandle')
%get the properrites from the handle
port = get(dstport)
%Display the port types of each port
port(1).PortType
port(2).PortType

More Answers (0)

Categories

Find more on Schedule Model Components in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!