replace_block and load_system

2 views (last 30 days)
Lucas
Lucas on 8 Jun 2012
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.

Accepted Answer

Kaustubha Govind
Kaustubha Govind on 8 Jun 2012
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 Comment
Kaustubha Govind
Kaustubha Govind on 8 Jun 2012
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'.

Sign in to comment.

More Answers (0)

Categories

Find more on Programmatic Model Editing in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!