简体   繁体   中英

MATLAB commands to find from the path of an input, the corresponding input in the parent subsystems

I have a simulink model with subsystems to which are linked inputs and outputs. I would like using MATLAB commands to find from the path of an input, the corresponding input in the parent subsystems.

Example:

My simulink model

Here I want to find "RootInput" using the path of "CurrentInput" using matlab commands.

I have tried using the ports but it doesn't work in all cases and on the Mathworks doc I haven't found a way to do it. Is there a solution?

You can find all blocks name by using (assuming you have a model in name of 'a.slx')

b=get_param('a/Subsystem','PortConnectivity') % this will give you connection information of SubSystem.
d=get_param(b(1).SrcBlock, 'BlockType') 

e=get_param(b(1).SrcBlock, 'Name')
f=get_param(b(1).SrcBlock, 'Ports')
h=get_param(b(1).SrcBlock, 'PortConnectivity')
i=get_param(b(1).SrcBlock, 'OutputSignalNames')

you can reach many parameters by using get_param(). related functions you can use are listed in https://www.mathworks.com/help/simulink/slref/get_param.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM