Delete Specific Simulink Block in a Linked Subsystem using m-script (MATLAB)

7 views (last 30 days)
How can I delete a specific block (eg: ShiftArith) in a linked subsystem programmatically using MATLAB? I have the block path for the block and I'm using "delete_block" command to delete the block. But I get the following error when executed.
delete_block(blkpath) Attempt to modify block in a linked subsystem. This can only be done by the block or its parent through their mask initialization code
Any methods to delete the block throughout the linked model.

Answers (1)

Mark McBroom
Mark McBroom on 27 Feb 2022
You have 2 options.
  1. if you want to delete the block for all instances of the subsystem, the you should open the simulink library and use the path to the block from within the simulink library to delete the block.
  2. If you want to delete the block only for one instance of the subsystem, you will have to first break the link to the library before Simulink will let you delete the block.

Community Treasure Hunt

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

Start Hunting!