I have a subsystem in Simulink with LConn and RConn blocks, some from Simulink Electrical and others from Simscape. How can I retrieve their type info from MATLAB?
Show older comments
I have a subsystem in Simulink with several LConn and RConn blocks. Some of them are from Simulink Electrical, and others are from Simscape. In Simulink, they appear as triangles or squares. How can I retrieve this information from MATLAB to determine their type?
Accepted Answer
More Answers (1)
Yifeng Tang
on 19 Mar 2025
I think this will help:
myBlock = 'example/Subsystem';
port_handles = get_param(myBlock,"PortHandles")
inports = port_handles.Inport;
outports = port_handles.Outport;
PhysConnL = port_handles.LConn;
PhysConnR = port_handles.RConn;
get_param(inports(1) ,"PortType")
get_param(outports(1) ,"PortType")
get_param(outports(2) ,"PortType")
get_param(PhysConnL(1),"PortType")
get_param(PhysConnR(1),"PortType")
You'll need the attached slx file to run the code.
This gives me:
port_handles = struct with fields:
Inport: 168.0007
Outport: [179.0007 180.0016]
Enable: []
Trigger: []
State: []
LConn: 181.0010
RConn: 182.0010
Ifaction: []
Reset: []
Event: []
ans = 'inport'
ans = 'outport'
ans = 'outport'
ans = 'connection'
ans = 'connection'
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!