Simulink - replace_block only works with SOME components?

1 view (last 30 days)
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 Comments
Viren
Viren on 8 Jan 2014
So, you suggest that I should create the Repeating Sequence block using it's constituents, and then set their values as necessary?
I think I can do that, but wouldn't it then be easier to just delete the constant and add_block the repeating sequence, and vice versa, depending on the user's input? Or is that what you were suggesting?

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by