Any way to figure out what your blocks are connected to in a model?
17 次查看(过去 30 天)
显示 更早的评论
inPorts = find_system(modelName,'SearchDepth',2,'BlockType','Inport');
outPorts = find_system(modelName,'SearchDepth',2,'BlockType','Outport');
I use that to get the Inport and Outport blocks in my model, but is there any way to see what they're connected to/from. I want to find out what's connected to my Outport block. I didn't know if I could trace it through the line that's connected to it to a Sum/Add block, or any other type of block.
0 个评论
采纳的回答
Kaustubha Govind
2012-6-8
Get the block's port handles using:
ph = get_param(gcb, 'PortHandles')
Examine ph.Inport and ph.Outport to get the handles to the block(s) connected at the input/output.
2 个评论
Kaustubha Govind
2012-6-11
1) outPorts is a cell-array, so you need to index into it using curly brackets: outPorts{i}
2) I think the LConn and RConn fields are only for Physical Modeling ports, so that won't work unless you have SimScape blocks.
3) Sorry, I just realized PortConnectivity is a better option than PortHandles in your case. I wrotea short sample, but you may need to modify/clean-up:
pc = get_param(outPorts{i}, 'PortConnectivity');
srcBlk = get_param(pc.SrcBlock, 'Name');
srcParent = get_param(pc.SrcBlock, 'Parent')
add_line(srcParent, [srcBlk '/1'], 'Out2/1', 'autorouting', 'on');
Kaustubha Govind
2012-6-13
Lucas: The number after the slash is just the port number. For the source block, it is the output port number and for the destination block, it is the input port number.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sources 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!