matlab/simulink中goto/from模块的使用方法

转自:http://blog.sina.com.cn/s/blog_62fb88190100xe5o.html

首先,介绍goto/from的用法:


1、在一个subsystem中放置一个goto,goto与一个经过运算后的输入信号连接;对goto中的tag命名,在tag visibility选择local/scope/global类型。


2、在另外一个subsystem或与goto同一个subsystem中放置from,在from中的goto tag处输入goto相同的名称,点击update tags。


经过上面2步就设置完成了该goto/from的组合使用。


不过,在开始使用goto/from搭建模型时,常常会遇到一个问题:


1、Goto/From connections cannot cross nonvirtual subsystem boundaries. The only exception is when a goto is connected to a state output port.


2、Invalid connection starts with 'untitled/CodeReuseSubsystem/Goto'.


3、Invalid connection ends with 'untitled/Atomic Subsystem/From'.


matlab/simulink中goto/from模块的使用方法_第1张图片


仿真时同时出现的上面这3个提示信息,仿真失败。仔细研究后就会发现:


goto和from在同一个subsystem中,无论goto设置为local还是global,都能正常进行仿真;在不同subsystem中,goto设置为global是就会报上述错误。


再深入研究提示的第一条信息后发现,该subsystem是nonvirtual,而goto不能穿过nonvirtual的subsystem,因此应该将该subsystem改为virtual。


选中该subsystem,在鼠标右键,在弹出的下拉菜单中选择“explorer”,在弹出的对话框中选中该subsystem,是否看到勾选了“treat as atomic unit”,这就是问题的根源所在了。


matlab/simulink中goto/from模块的使用方法_第2张图片

取消勾选该选项,再进行仿真,问题解决。



你可能感兴趣的:(MATLAB和SIMULINK)