Simulink - replace_block only works with SOME components?
4 ビュー (過去 30 日間)
古いコメントを表示
Hi all
I have a virtual subsystem with a mask. The mask allows the user to select either Enable or Disable for an option (see screenshot). Depending on the option chosen, I want the mask to replace a Constant with a Repeating Sequence or the other way around.
I have the following code:
switch get_param(gcb,'control')
case 'Enable'
replace_block([gcb,'/controlSequence'],'Constant','simulink/Sources/Repeating Sequence','noprompt');
case 'Disable'
replace_block([gcb,'/controlSequence'],'Repeating Sequence','Constant','noprompt');
end
This code works perfectly when I replace 'Repeating Sequence' with 'Inport', or 'Step' (which is in the SAME 'Sources' section!), just not with Repeating Sequence.
Any ideas why?
2 件のコメント
Duke
2014 年 1 月 8 日
If you put the Repeating Sequence in a model, and have it selected and go to the MatLab command window and type get_param(gcb, 'BlockType') you'll see it return that it's a subsystem. That's why it's not working for you, because there is no such block as a Repeating Sequence, it's just a masked subsystem.
You should be able to replace it with a subsystem and just use get_param and set_param with add_block to excatly relacate the block you need. I've done it with compare to constant blocks before.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Author Block Masks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!