枚举 Simulink 中模块的输入端口和输出端口
如何在 Simulink 中枚举模块的输入和输出句柄?到目前为止,我已经尝试使用以下内容,其中“sfunc”已设置为块句柄:
inports = get_param(sfunc, 'Inport')
outports = get_param(sfunc, 'Outport')
它返回一个二维数组,其大小等于指定端口的数量。但是当我运行以下命令(使用“输入端口”或“输出端口”)时,
get_param(inports, 'Handle')
它指出该数组必须是一个向量。我以正确的方式处理这件事吗?如果是这样,如何将数组转换为向量?本质上,我想做的是获取连接到该块的线路的句柄,以便稍后在用新块替换当前块后将它们链接起来。对此的任何帮助将不胜感激。
How would one enumerate the inport and outport handles of a block problematically in Simulink? So far I have tried using the following, where 'sfunc' has already been set to the block handle:
inports = get_param(sfunc, 'Inport')
outports = get_param(sfunc, 'Outport')
Which returns a two dimensional array where its size is equal to the number of specified ports. But when I run the following (with either 'inports' or 'outports')
get_param(inports, 'Handle')
It states that the array must be a vector. Am I going about this the right way? And if so, how do I convert an array into a vector? Essentially what I am trying to do is get the handle of the lines connected to the block so I can link them up later after replacing the current block with a new one. Any help on this would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用参数 PortHandles,这将为您提供一个包含 Inport、Outport、EnablePort 等字段的结构。 Inport 和 Outport 字段将是一个句柄数组,即端口数量的大小。
Try using the parameter PortHandles, this will give you a structure with fields like Inport, Outport, EnablePort, etc. The fields Inport and Outport will be an array of handles, the size of the number of ports.