Matlab Simulink遮罩编辑器:替换块
我想在Matlab/Simulink 2016b中将子系统的块更改为Matlab Simulink遮罩编辑器:替换块,matlab,simulink,Matlab,Simulink,我想在Matlab/Simulink 2016b中将子系统的块更改为内置/输入端口或内置/常量 disp(PortStat) switch PortStat case 'off' if strcmp(get_param([gcb '/eng'],'BlockType'),'Inport') disp('replace inport to constant') replace([gcb '/eng'],'built-in/Inport',
内置/输入端口
或内置/常量
disp(PortStat)
switch PortStat
case 'off'
if strcmp(get_param([gcb '/eng'],'BlockType'),'Inport')
disp('replace inport to constant')
replace([gcb '/eng'],'built-in/Inport','built-in/Constant')
get_param([gcb '/eng'],'BlockType')
replace_block([gcb '/eng'],'built-in/Inport','built-in/Constant')
get_param([gcb '/eng'],'BlockType')
end
case 'on'
if strcmp(get_param([gcb '/eng'],'BlockType'),'Inport')
disp('inport already exist')
end
if strcmp(get_param([gcb '/eng'],'BlockType'),'Constant')
disp('replace constant to inport')
replace([gcb '/eng'],'built-in/Inport');
end
end
切换复选框将导致以下输出:
on
inport already exist
off
replace inport to constant
ans =
myModel/Subsys/eng
ans =
Inport
ans =
Inport
块类型不会更改。但是为什么呢
进一步资料:
- Syubsystem不是库对象
- 我运行
set_param(gcb,'MaskSelfModifiable','on')代码>和灰色字段“允许库块修改其在掩码编辑器的初始化窗格上的内容”已签出
replace_block(gcb, 'Inport', 'Constant');
或
反之亦然。块类型为“常量”或“输入端口”,不包括您在显示器中看到的“内置”。此外,上述调用将替换gcb内具有源块类型的所有块。因此,如果有多个块具有相同的块类型,但只想替换其中一个,则不能使用此函数
replace_block(gcb, 'Constant', 'Inport');