帮助中心帮助中心
在 Simulink 模型中查找指定类型的模块
bl = Simulink.findBlocksOfType(sys,type)
bl = Simulink.findBlocksOfType(sys,type,options)
bl = Simulink.findBlocksOfType(sys,type,Param1,Value1,...,ParamN,ValueN)
bl = Simulink.findBlocksOfType(sys,type,Param1,Value1,...,ParamN,ValueN,options)
示例
bl = Simulink.findBlocksOfType(sys,type) 返回模型或子系统 sys 中指定类型的所有模块的句柄。
bl
sys
type
bl = Simulink.findBlocksOfType(sys,type,options) 匹配 FindOptions 对象指定的条件。
options
FindOptions
bl = Simulink.findBlocksOfType(sys,type,Param1,Value1,...,ParamN,ValueN) 查找参数具有指定值的模块。
bl = Simulink.findBlocksOfType(sys,type,Param1,Value1,...,ParamN,ValueN,options) 查找参数具有指定值且匹配 FindOptions 对象所指定条件的模块。
全部折叠
打开示例。然后,加载 vdp 模型。
vdp
load_system('vdp')
获取 vdp 模型中所有 Integrator 模块的句柄。
Simulink.findBlocksOfType('vdp','Integrator')
ans = 2×1 334.0022 357.0027
要返回模块名称而不是句柄,请使用 getfullname 函数。
getfullname
getfullname(Simulink.findBlocksOfType('vdp','Integrator'))
ans = 2x1 cell {'vdp/x1'} {'vdp/x2'}
打开示例。然后,加载 sldemo_clutch 模型。
sldemo_clutch
load_system('sldemo_clutch')
创建一个 FindOptions 对象。
f = Simulink.FindOptions('SearchDepth',1);
使用该对象将模型中 Goto 模块的搜索范围限制到 Unlocked 子系统。
Unlocked
b = Simulink.findBlocksOfType('sldemo_clutch/Unlocked','Goto',f)
b = 2×1 676.0015 678.0015
在其中查找模块的模型或子系统,指定为字符向量或字符串数组。
示例: 'vdp' "f14/Aircraft Dynamics Model"
'vdp'
"f14/Aircraft Dynamics Model"
模块类型,指定为字符向量或字符串标量。使用 get_param 和 'BlockType' 参数获取模块类型。
get_param
'BlockType'
simulink.FindOptions
搜索约束,指定为 Simulink.FindOptions 对象。
Simulink.FindOptions
示例: Simulink.FindOptions('SearchDepth',1)
Simulink.FindOptions('SearchDepth',1)
搜索结果,以句柄数组形式返回。
在 R2018a 中推出
Simulink.FindOptions | Simulink.findBlocks | Simulink.allBlockDiagrams
Simulink.findBlocks
Simulink.allBlockDiagrams
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office