Can I use comment through in a dynamic Simulink mask?

12 views (last 30 days)
I'd like to create a Simulink mask where I can comment through or uncomment a sub block of the mask based on one of the mask parameters.
E.g., let s = 0 or 1 be one of the mask parameters. In the Initialization tab of the Mask editor, I have:
mask_block = gcb
switch s
case 0
set_param([mask_block '/test_block'], 'Commented', 'through')
case 1
set_param([mask_block '/test_block'], 'Commented', 'off')
error('s must be 0 or 1')
This gives an error as soon as I click Apply in the mask editor:
Error in 'test_lib/test_mask':Initialization command cannot be evaluated Caused by: Block 'test_lib/test_mask/test_block/ cannot be commented during execution of a callback.
The interesting thing is that I have no issue if I want to delete the block instead. Am I forced to delete and recreate a block (which could be pretty complicated) in order to get the right dynamic mask behavior? That would be a shame when this very convenient comment through feature is available.

Answers (5)

John B
John B on 19 Sep 2014
I am having the same issue. Strange that there is no problem deleting blocks or adding new blocks, yet commenting one out is not allowed.

Mark on 26 Nov 2014
I'm also looking to do something similar - have a button which runs a script to comment out debug logic & scopes in a model. Would like to hear if there's a workaround to the 'cannot be commented out/through during execution of a callback' problem.

Guilherme on 9 Dec 2015
I have the same problem!

Fabio Reway
Fabio Reway on 23 Nov 2016
Hi. Is there no workaround for this issue yet? Thanks

x qs
x qs on 22 Apr 2021
use the 'Variant Subsystem' block for instead
  1 Comment
x qs
x qs on 22 Apr 2021
one of subsystem connect the input/out directly, another not.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by