Documentation

get_param

获取参数名称和值

描述

example

ParamValue= get_param(目的,Parameter)returns the name or value of the specified parameter for the specified model or block object. Open or load the Simulink®首先。

Tip

如果您拨打多个电话get_param对于同一块,然后使用数字手柄指定块比使用完整的块路径更有效。利用getSimulinkBlockHandle获取块手柄。

有关参数名称,请参见:

例子

全部收缩

加载VDPmodel.

load_system('vdp');

Get the value for the表达block parameter.

BlockParameterValue = get_param('VDP/FCN','Expression')
BlockParameTervalue = 1 -U*U

Get the value for thesolverTypemodel 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 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模型参数VDPmodel.

ModelParameterValue = get_param('vdp',“模型version')
ModelParameterValue = 1.6

获取块路径和名称的列表VDPmodel.

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 theFCNblock.

BlockDialogParameters = get_param('VDP/FCN',“对话参数”)
BlockDialogParameters = Expr:[1x1 struct] Sampletime:[1x1 struct]

Get the value for theExprblock 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 theFCNblock.

fcnblockhandle = getSimulinkBlockHandle('VDP/FCN',true);

利用the block handle withget_paramand get the value for theExprblock parameter.

blockParameterValue = get_param(fcnblockhandle,'Expression')
BlockParameTervalue = 1 -U*U

获取块路径和名称的列表VDPmodel.

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 theBlockTypeparameter for each of the blocks in theVDPmodel.

blocktypes = get_param(块Paths,'BlockType')
BlockTypes = 'Fcn' 'SubSystem' 'SubSystem' 'Gain' 'Mux' 'Product' 'Scope' 'Sum' 'Integrator' 'Integrator' 'Outport' 'Outport'

输入参数

全部收缩

指定为数字句柄或字符向量,多个块的字符向量的单元格数组,或0root。数字手柄必须是标量。您还可以获取行和端口的参数,但是必须使用数字把手来指定它们。

Tip

如果您拨打多个电话get_paramfor 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 of model or block, or root, specified as a character vector or0root。该表显示了特殊情况。

指定参数 结果
“对象参数”

返回一个结构数组,其中指定对象的参数名称(模型,块或根)作为结构中的单独字段。

“对话参数”

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返回
“对象参数”

带有指定对象(模型,块或根)参数名称的结构数组作为结构中的单独字段。

“对话参数”

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'模拟'

在R2006a之前引入