Can I use comment through in a dynamic Simulink mask?

조회 수: 9 (최근 30일)
Dara Parsavand
Dara Parsavand 2014년 6월 10일
댓글: Daniel Gomez-Acero 2023년 7월 24일
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')
otherwise
error('s must be 0 or 1')
end
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.
Dara
  댓글 수: 1
Daniel Gomez-Acero
Daniel Gomez-Acero 2023년 7월 24일
I think I solve the problem at least in Matlab 2023a I haven't test in prevous versions.
try allowing the modification of the mask by using this line in the initialization code of the mask
set_param(gcb, 'MaskSelfModifiable', 'on');
if this is not enough try adding this line for each block you want to modify:
set_param(block_name,'MaskSelfModifiable','on')
you can inspire yourself with this page :
https://fr.mathworks.com/help/simulink/ug/create-dynamic-masked-subsystems.html

댓글을 달려면 로그인하십시오.

답변 (5개)

John B
John B 2014년 9월 19일
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
Mark 2014년 11월 26일
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
Guilherme 2015년 12월 9일
I have the same problem!

Fabio Reway
Fabio Reway 2016년 11월 23일
Hi. Is there no workaround for this issue yet? Thanks

x qs
x qs 2021년 4월 22일
use the 'Variant Subsystem' block for instead
  댓글 수: 1
x qs
x qs 2021년 4월 22일
one of subsystem connect the input/out directly, another not.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Author Block Masks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by