MATLAB 命令从输入的路径中查找父子系统中的相应输入

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

我有一个 simulink 模型,其中包含链接输入和输出的子系统。我想使用 MATLAB 命令从输入路径中找到父子系统中的相应输入。

示例:

My simulink model

这里我想使用matlab命令使用“CurrentInput”的路径找到“RootInput”。

我尝试过使用这些端口,但它并非在所有情况下都有效,而且在 Mathworks 文档中我还没有找到执行此操作的方法。有解决办法吗?

您可以使用(假设您有一个名为 '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')

您可以使用 get_param() 获得许多参数。 https://www.mathworks.com/help/simulink/slref/get_param.html

中列出了您可以使用的相关功能