【问题标题】:replacing blocks in matlab在matlab中替换块
【发布时间】:2017-03-21 12:29:38
【问题描述】:

我知道这可能很简单,但我至少被困了一个小时.. 我只是无法找出错误是什么。(我阅读了文档) 任何帮助表示赞赏。提前致谢

function y = in_out_modeling(~)

    model_name = 'modeladvisor_test';

    all_input_blocks = find_system('modeladvisor_test', 'FollowLinks', 'on', 'LookUnderMasks', 'all', 'BlockType', 'In');
    all_output_blocks = find_system('modeladvisor_test', 'FollowLinks', 'on', 'LookUnderMasks', 'all', 'BlockType', 'Out');

    for i=1:length(all_input_blocks)
        replace_block(model_name, all_input_blocks(i), 'From');
    end

    for i=1:length(all_output_blocks)
        replace_block(model_name, all_output_blocks(i), 'Goto');
    end

【问题讨论】:

  • 你能告诉我们你的问题到底是什么吗?您收到错误消息吗? minimal working example 证明您的问题也会有所帮助。
  • 就是这样:没有错误,没有警告,什么都没有.. >> in_out_modeling >> in_out_modeling(modeladvisor_test) 警告:'modeladvisor_test/Subsystem' 的输出端口 2 未连接。警告:在“modeladvisor_test/Subsystem”(输入端口:2)上发现未连接的输入线警告:在“modeladvisor_test/Subsystem”(输入端口:1)上发现未连接的输入线>> in_out_modeling('modeladvisor_test')
  • 这就是我的命令窗口的样子。 Simulink 模型不会改变。

标签: matlab replace block simulink


【解决方案1】:

replace_block 通过将 BlockType 作为输入来替换块。您正在发送这些块的路径作为不起作用的输入。尝试使用,

replace_block(model_name, 'Inport', 'From')

以上将提示您进行每次更换。如果您不想收到提示,请使用

replace_block(model_name, 'Inport', 'From', 'noprompt')

replace_block 也将返回它插入的新块的路径。您可以使用该列表来验证您是否已替换所有块。

如果您想使用 find_system 进行自己的搜索,请使用“名称”作为 replace_block 的参数。

replace_block(model_name, 'Name', all_input_blocks(i), 'From', 'noprompt')

【讨论】:

  • 谢谢先生,帮了大忙!
【解决方案2】:

没有BlockTypeInOut 的块。因此all_input_blocks 是空的并且您没有调用任何replace_block 代码。对于输出也是如此。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-02-24
    • 2014-09-15
    • 2013-05-24
    • 1970-01-01
    • 2018-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多