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)
Best Answer