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!