MATLAB: Does the function REPLACE_BLOCK give an error when using dynamic masking of a library block in Simulink 7.1 (R2008a)

add_blockdelete_blockdynamiclibrarymaskingreplace_blocksimulink

An error occurs when using the REPLACE_BLOCK function in dynamic masking of a library block.
The reproduction steps are provided below:
Open the attached example "rate_lib.mdl" and copy this to a new Simulink model. Open the mask and change the 'Reset'. This results in an error dialog with the following message:
Error due to multiple causes:
--> Inport block does not have a parameter name 'Value'.
--> Error evaluating 'MaskCallback' callback for Ratelimiter block (mask) 'Ratelimiter2'. Inport block does not have a parameter named 'Value'.
Breaking the link resolves the error; however this is not a suitable workaround.
It is mentioned in the Help Documentation for "Mask Editor" (Mask Editor –> Parameters Pane –> Options for Selected Parameter Panel –> Callback) that changing the configuration of the subsystem in the mask parameter callback function is not recommended. So the REPLACE_BLOCK function should be done in mask initialization. However, this also does not work.

Best Answer

The block is a linked block and for this reason the REPLACE_BLOCK function does not look under the link and hence fails to replace the block. To resolve the issue, specify the FollowLinks option in the REPLACE_BLOCK usage as shown below:
replace_block(sys, 'FollowLinks', 'on', 'Name', ...)
Another workaround is to use the functions DELETE_BLOCK and ADD_BLOCK as shown in the attached example 'rate_lib_new.mdl'.