Why don't S-Function blocks with dynamic input and output ports update when saving the blocks in a library or model in Simulink 7.8 (R2011b)?

4 views (last 30 days)
My Simulink model contains a Level 2 MATLAB S-Function block. The number of input and output ports are dynamically updated based on mask parameters.
The issue I am running into occurs when saving and loading the Simulink block in a library or model causes it appear invalid.
Even though the commands
get_param(gcb, 'NumInputPorts')
get_param(gcb, 'NumOutputPorts')
output the value I've inputted in my dialog mask parameter, the block that is drawn only contains 1 input and 1 output (the defaults).
If I manually set the number of input and output ports from the MATLAB Command Window as follows
set_param(gcb, 'NumInputPorts'
the block gets updated correctly. Why does this happen?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 19 Apr 2012
In order for the number of ports to update properly, the "Allow Library Block to Modify its Content" option must be enabled for the block. To do this, please take the following steps:
1. Right click the block and select 'Edit Mask'.
2. Go to the 'Initialization' tab in the Mask Editor.
3. Check the "Allow Library Block to Modify its Content" checkbox.
OR
1. Select the block
2. Enter this command at the MATLAB Command Window:
>> set_param(gcb, 'MaskSelfModifiable', 'on');

More Answers (0)

Products


Release

R2011b

Community Treasure Hunt

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

Start Hunting!