replace_block and load_system
2 次查看(过去 30 天)
显示 更早的评论
I have 2 questions, first being:
1. Can replace_block replace blocks with custom made blocks? I'm having some trouble with that so I don't know if it's supported or not. Can you tell replace block to only replace blocks on the top level or in a subsystem?
2. Can you run load_system and tell it not to save the changes you made? I want to use replace_block, run my model and exit leaving the model in its original state.
0 个评论
采纳的回答
Kaustubha Govind
2012-6-8
Yes, you should be able to replace blocks using replace_block with custom blocks as well. You will need to specify the full path of the library for custom blocks. Also, you might need to make sure that the custom library is loaded using load_library.
To have replace_block replace only inside a subsystem, you need to specify the path of the subsystem as the first argument (instead of the name of the top-level model).
To have it replace only blocks in the top level, use the 'SearchDepth' argument as follows:
>> replace_block('vdp', 'SearchDepth', 1, 'BlockType', 'Gain', 'Integrator')
If you are loading/opening a model, you also need to close it using close_system. You can tell close_system to not save changes by using the saveflag argument:
>> close_system('vdp', 0)
1 个评论
Kaustubha Govind
2012-6-8
No, you just need to make sure that model is on the MATLAB path. Then, run load_system('External_In_Out_Blocks'). Then, if that library has a block with the name (let's say) 'My Custom Block', the path you need to use for the new_blk argument is 'External_In_Out_Blocks/My Custom Block'.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Programmatic Model Editing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!