【发布时间】:2017-05-02 03:21:59
【问题描述】:
我想在 Matlab/Simulink 2016b 中将子系统的一个模块更改为 built-in/Inport 或 built-in/Constant。
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
BlockType 不会改变。但为什么呢?
更多信息:
- Syubsystem 不是库对象。
- 我运行
set_param(gcb, 'MaskSelfModifiable', 'on');,蒙版编辑器的初始化窗格上的灰色字段允许库块修改其内容是已签出。
【问题讨论】: