simulink - Simulink:在停止时引用掩码块
问题描述
我创建了一个动态掩码块,根据我的掩码参数,我删除其中一条线(我们称之为 myFirstLine)并添加另一条线(我们称之为 mySecondLine)。当我第一次运行模拟时,一切都很好。但是,在第二次运行中,模拟抱怨它无法运行掩码块的初始化。这似乎是正确的,因为它在第一次模拟运行中删除了 myFirstLine,而在第二次模拟运行中没有要删除的 myFirstLine。我的掩码块是库块。所以,我想知道在模拟停止后是否可以将掩码块刷新为其默认值。
作为 MWE,请考虑我有一个带有参数“numBLK”的掩码块。我的掩码块初始化中有以下代码:
if numBLK > 1
delete_line('myMaskBLK','myBLK_1/1','myOut/1');
add_block('simulink/Math Operations/Matrix Concatenate','myMaskBLK/myMux','NumInputs','numBLK','ConcatenateDimension','1');
add_line('myMaskBLK','myBLK_1/1','myMux/1');
for counter = 2 : numBLK
add_block('myMaskBLK/myBLK',strcat('myMaskBLK/myBLK',num2str(counter)));
add_line('myMaskBLK',strcat('myMaskBLK/myBLK',num2str(counter)),strcat('myMux/',num2str(counter)));
end
end
解决方案
推荐阅读
- python - 如何将第二个 csv 的未重复行添加到第一个的末尾并合并到新的 csv?
- react-native - 无法让相机使用 expoTHREE 和 expoGRAPHICS 在 React-native 项目中创建 AR 场景
- machine-learning - 在语言建模中,为什么我必须在每个新的训练时期之前初始化隐藏权重?(火炬)
- dart - setState Dart/Flutter 中带有花括号的胖箭头符号
- javascript - 在 Leaflet 上缓慢加载 KML 文件...我可以加载其中的一部分吗?
- css - CSS 转换:翻译在 IOS 上的行为不正确
- angular - 为什么 ngx-chart TreeMap 标签不显示在 IE11 中?
- javascript - 如何对齐屏幕中垂直对齐的内容?
- angular - 从 html 文件根据条件调用函数而不使用 *ngIf
- angular - 从 HTML/Angular 应用程序访问移动图库