| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |
| On this page… |
|---|
This check box is enabled only if the masked subsystem resides in a library. Checking this option allows the block's initialization code to modify the contents of the masked subsystem, i.e., it lets the code add or delete blocks and set the parameters of those blocks. Otherwise, an error is generated when a masked library block tries to modify its contents in any way. To set this option at the MATLAB prompt, select the self-modifying block and enter the following command.
set_param(gcb, 'MaskSelfModifiable', 'on');
Then save the block.
You can create masked library blocks that can modify their structural contents. These self-modifying masks allow you to
Modify the contents of a masked subsystem based on parameters in the mask parameter dialog box or when the subsystem is initially dragged from the library into a new model.
Vary the number of ports on a multiport S-Function that resides in a library.
To create a self-modifying mask using the Mask Editor:
Unlock the library (see Modifying a Library).
Select the block in the library.
Select Edit Mask from the Edit menu or the block's context menu. The Mask Editor opens.
In the Mask Editor's Initialization pane, select the Allow library block to modify its contents option.
Enter the code that modifies the masked subsystem in the mask's Initialization pane.
Click Apply to apply the change or OK to apply the change and dismiss the Mask Editor.
Lock the library.
To create a self-modifying mask from the command line:
Unlock the library using the following command:
set_param(gcs,'Lock','off')
Specify that the block is self-modifying by using the following command:
set_param(block_name,'MaskSelfModifiable','on')
where block_name is the full path to the block in the library.
The library selfModifying_example.mdl contains a masked subsystem that modifies its number of input ports based on a selection made in the subsystem's Mask Parameters dialog box.

Select the subsystem then select View Mask from the Edit menu or the block's context menu. The Mask Editor opens. The Mask Editor's Parameters pane defines one mask parameter variable numIn that stores the value for the Number of inports option. This Mask Parameters dialog box callback adds or removes Input ports inside the masked subsystem based on the selection made in the Number of inports list.

To allow the dialog callback to function properly, the Allow library block to modify its contents option on the Mask Editor's Initialization pane is selected. If this option were not selected, copies of the library block could not modify their structural contents and changing the selection in the Number of inports list would produce an error.

![]() | Creating Dynamic Mask Dialog Boxes | Best Practices for Using M-Code in Masks | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |