MATLAB: Are signals disconnected after reloading the model when masking a built-in block

disconnectmasksignalsimulink

I created a custom mask on a Simulink block that allows to modify the number of ports of the original block and I saved it as a library block in a custom library. When I now use this block in a model and change the number of ports I see the following strange behavior:
If the library block has by default 2 in-ports and the block is configured for 3 in-ports then every time the model is opened, the third input signal is disconnected from the block.
What can I do to prevent this?

Best Answer

Changing the number of ports modifies the "contents" of the block that is masked. Such modifications are allowed for library blocks, but only if "Allow library block to modify its contents" is enabled on the library block. You can find this option in the Initialization tab of the Mask Editor. Typically the initialization commands are responsible for modifying the contents of the masked block.