Effacer les filtres
Effacer les filtres

Any way to figure out what your blocks are connected to in a model?

14 vues (au cours des 30 derniers jours)
Lucas
Lucas le 8 Juin 2012
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.

Réponse acceptée

Kaustubha Govind
Kaustubha Govind le 8 Juin 2012
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 commentaires
Kaustubha Govind
Kaustubha Govind le 11 Juin 2012
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
Kaustubha Govind le 13 Juin 2012
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by