How to keep SID when using "replace_block"?

1 view (last 30 days)
I work with MATLAB R2016b and I cannot make use of keeping the SID when replacing blocks.
I have an old project where we copy the partial models from one model to another with "replace_block".
However, using the 'KeepSID' option, the SID Number will be reset when the "replace_block" is applied.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 4 Jul 2022
This option is still available but not documented well. You can keep the SID using the following commands:
>> open_system('vdp');
>> get_param('vdp/Mu','BlockType')
ans =
  'Gain'
>> simulinkID = Simulink.ID.getSID('vdp/Mu')
simulinkID =
  'vdp:4'
>> blk = sprintf('simulink/Math\nOperations/Bias');
>> replace_block('vdp','Name','Mu',blk,'KeepSID');
>> get_param('vdp/Mu','BlockType')
ans =
  'Bias'
>> simulinkID = Simulink.ID.getSID('vdp/Mu')
simulinkID =
  'vdp:4'

More Answers (0)

Categories

Find more on Programmatic Model Editing in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2016b

Community Treasure Hunt

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

Start Hunting!