MATLAB: Is there a way to use the DELETE_BLOCK function in model StopFcn callback to delete blocks in SIMULINK 6.4 (R2006a)

removeroutinesimulink

When I use the following command in the StopFcn callback of the attached model example.mdl
delete_block('example/Gain')
I receive the following error:
Error evaluating 'StopFcn' callback of block_diagram 'example'. Error using ==> delete_block
Cannot delete 'example/Gain' while simulation is running.
I would like to have the option of deleting blocks in the StopFcn callback of a model in SIMULINK.

Best Answer

The ability to delete blocks in the STOPFCN callback of a model is not available in SIMULINK.
There are no known workarounds.