get_param
获取参数名称和值
描述
returns the name or value of the specified parameter for the specified model or block object. Open or load the Simulink®首先。ParamValue
= get_param(目的
,Parameter
)
Tip
如果您拨打多个电话get_param
对于同一块,然后使用数字手柄指定块比使用完整的块路径更有效。利用getSimulinkBlockHandle
获取块手柄。
有关参数名称,请参见:
例子
获取块参数值和模型参数值
加载VDP
model.
load_system('vdp');
Get the value for the表达
block parameter.
BlockParameterValue = get_param('VDP/FCN','Expression')
BlockParameTervalue = 1 -U*U
Get the value for thesolverType
model parameter.
solverType= get_param('vdp',“ solverType”)
solverType= Variable-step
获取根参数名称和值
Get a list of global parameter names by finding the difference between the Simulink root parameter names and the model parameter names.
rootparameternames = fieldNames(get_param(0,“对象参数”);load_system('vdp') ModelParameterNames = fieldnames(get_param('vdp',“对象参数”);globalParameterNames = setDiff(rootparameternames,modelParameterNames)
globalParameterNames ='autoSaveOptions''cachefolder'“ callbacktractracing''artareCoding'。。。“ Currentsystem”
获取全局参数的值。
globalParameTervalue = get_param(0,“ Currentsystem”)
GlobalParameterValue = vdp
Get Model Parameter Names and Values
Get a list of model parameters for theVDP
模型 。
load_system('vdp')modelParameterNames = get_param('vdp',“对象参数”)
ModelParameterNames = Name: [1x1 struct] Tag: [1x1 struct] Description: [1x1 struct] Type: [1x1 struct] Parent: [1x1 struct] Handle: [1x1 struct] . . . Version: [1x1 struct]
Get the current value of theModelVersion
模型参数VDP
model.
ModelParameterValue = get_param('vdp',“模型version')
ModelParameterValue = 1.6
Get All Blocks and a Parameter Value
获取块路径和名称的列表VDP
model.
load_system('vdp') BlockPaths = find_system('vdp','类型','堵塞')
BlockPaths = 'vdp/Fcn' 'vdp/More Info' 'vdp/More Info/Model Info' 'vdp/Mu' 'vdp/Mux' 'vdp/Product' 'vdp/Scope' 'vdp/Sum' 'vdp/x1' 'vdp/x2' 'vdp/Out1' 'vdp/Out2'
Get a list of block dialog parameters for theFCN
block.
BlockDialogParameters = get_param('VDP/FCN',“对话参数”)
BlockDialogParameters = Expr:[1x1 struct] Sampletime:[1x1 struct]
Get the value for theExpr
block parameter.
BlockParameterValue = get_param('VDP/FCN','Expr')
BlockParameTervalue = 1 -U*U
使用块句柄获取块参数值
如果您拨打多个电话get_param
对于同一块,然后使用块手柄比将完整块路径指定为字符向量,例如,例如,例如,'VDP/FCN'
。
您可以在随后的调用中使用块句柄get_param
或者set_param
。If you examine the handle, you can see that it contains a double. Do not try to use the number of a handle alone (e.g.,5.007
) because you usually need to specify many more digits than MATLAB®显示。而是将句柄分配给变量,并使用该变量名称指定块。
利用getSimulinkBlockHandle
加载VDP
如有必要(通过指定真的
), and get a handle to theFCN
block.
fcnblockhandle = getSimulinkBlockHandle('VDP/FCN',true);
利用the block handle withget_param
and get the value for theExpr
block parameter.
blockParameterValue = get_param(fcnblockhandle,'Expression')
BlockParameTervalue = 1 -U*U
显示模型中所有块的块类型
获取块路径和名称的列表VDP
model.
load_system('vdp') BlockPaths = find_system('vdp','类型','堵塞')
BlockPaths = 'vdp/Fcn' 'vdp/More Info' 'vdp/More Info/Model Info' 'vdp/Mu' 'vdp/Mux' 'vdp/Product' 'vdp/Scope' 'vdp/Sum' 'vdp/x1' 'vdp/x2' 'vdp/Out1' 'vdp/Out2'
Get the value for theBlockType
parameter for each of the blocks in theVDP
model.
blocktypes = get_param(块Paths,'BlockType')
BlockTypes = 'Fcn' 'SubSystem' 'SubSystem' 'Gain' 'Mux' 'Product' 'Scope' 'Sum' 'Integrator' 'Integrator' 'Outport' 'Outport'
输入参数
目的
—Name or handle of a model or block, or root
处理|角色向量|cell array of character vectors|字符串数组|0
指定为数字句柄或字符向量,多个块的字符向量的单元格数组,或0
root。数字手柄必须是标量。您还可以获取行和端口的参数,但是必须使用数字把手来指定它们。
Tip
如果您拨打多个电话get_param
for the same block, then specifying a block using a numeric handle is more efficient than using the full block path. UsegetSimulinkBlockHandle
获取块手柄。Do not try to use the number of a handle alone (e.g.,5.007
) because you usually need to specify many more digits than MATLAB displays. Assign the handle to a variable and use that variable name to specify a block.
Specify0
要获取root参数名称,包括当前Simulink会话的全局参数和模型参数。金宝app
Global parameters include Editor preferences and金宝appSimulink Coder™parameters.
模型参数包括配置参数,金宝appSimulink编码器parameters, andSimulink Code Inspector™parameters.
例子:'VDP/FCN'
Parameter
—Parameter of model or block, or root
角色向量|string scalar
Parameter of model or block, or root, specified as a character vector or0
root。该表显示了特殊情况。
指定参数 | 结果 |
---|---|
“对象参数” |
返回一个结构数组,其中指定对象的参数名称(模型,块或根)作为结构中的单独字段。 |
“对话参数” |
Returns a structure array with the block dialog box parameter names as separate fields in the structure. If the block has a mask, the function instead returns the mask parameters. |
Parameter name, e.g.,'BlockType' 。指定任何模型或块参数,或块对话框参数。 |
返回指定模型或块参数的值。 如果将多个块指定为单元格数组,请返回一个单元格数组,该数组具有所有块共有的指定参数的值。单元格数组中的所有指定块都必须包含参数,否则函数返回错误。 |
例子:“对象参数”
Data Types:char
Output Arguments
ParamValue
- 指定模型或块的指定参数的名称或值,或root
any data type, depending on the parameter
指定模型或块或根的指定参数的名称或值。如果指定多个对象,则输出是一个单元格对象。该表显示了特殊情况。
指定参数 | ParamValue返回 |
---|---|
“对象参数” |
带有指定对象(模型,块或根)参数名称的结构数组作为结构中的单独字段。 |
“对话参数” |
A structure array with the block dialog box parameter names as separate fields in the structure. If the block has a mask, the function instead returns the mask parameters. |
Parameter name, e.g.,'BlockType' |
The value of the specified model or block parameter. If multiple blocks are specified as a cell array, returns a cell array with the values of the specified parameter common to all blocks. |
If you get the root parameters by specifyingget_param(0,'ObjectParameters')
, then the outputParamValue
是一个具有根参数名称的结构数组,作为结构中的单独字段。每个参数字段都是包含这些字段的结构:
类型 - 参数类型值为:
“布尔人”
,'细绳'
,'int'
,'真实的'
,'观点'
,'长方形'
,'矩阵'
,``枚举''
,“端口”
, or'列表'
枚举 - 仅适用于
``枚举''
参数类型属性 - 定义参数属性的字符向量的单元格数组。值为:
“读写”
,'只读'
,'read-only-if-compiled'
,“只写”
,'nont-eval'
,'always-save'
,“永无止境”
,'nondirty'
, or'模拟'
See Also
在R2006a之前引入
matlab命令
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择一个网站
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:。
您还可以从以下列表中选择一个网站:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
美洲
- AméricaLatina(Español)
- 加拿大(英语)
- 美国(英语)