Documentation

get_param

Get parameter names and values

Syntax

  • RootParamNames = get_param(0,'ObjectParameters') example
  • GlobalParamValue = get_param(0,GlobalParam) example
  • ModelParamNames = get_param(Model,'ObjectParameters') example
  • ModelParamValue = get_param(Model,ModelParam) example
  • ModelParamDefaultValue = get_param(0,ModelParam)
  • BlockParamNames = get_param(Block,'ObjectParameters')
  • BlockDialogParamNames = get_param(Block,'DialogParameters') example
  • BlockParamValue = get_param(Block,BlockParam)
  • BlockDialogParamValue = get_param(Block,BlockDialogParam) example

Description

example

RootParamNames = get_param(0,'ObjectParameters') returns a structure array with the root parameter names as separate fields in the structure. Includes both the global parameters and model parameters.

example

GlobalParamValue = get_param(0,GlobalParam) returns the value of a global parameter for the current Simulink session.

example

ModelParamNames = get_param(Model,'ObjectParameters') returns a structure array with the model parameter names as separate fields in the structure. Open or load the Simulink® model first.

example

ModelParamValue = get_param(Model,ModelParam) returns the value of a model parameter.

ModelParamDefaultValue = get_param(0,ModelParam) returns the default value of a model parameter.

BlockParamNames = get_param(Block,'ObjectParameters') returns a structure array with the block parameter names as separate fields in the structure. Includes the block dialog box parameters.

example

BlockDialogParamNames = get_param(Block,'DialogParameters') 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.

BlockParamValue = get_param(Block,BlockParam) returns the value of a block parameter.

example

BlockDialogParamValue = get_param(Block,BlockDialogParam) returns the value of a block dialog box parameter. If Block is a cell array, returns a cell array with the values of the specified parameter common to all blocks. All of the blocks in the Block cell array must contain the BlockDialogParam or an error occurs.

Examples

Get Global Parameter Names and Values

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,'ObjectParameters'));
load_system('vdp')
ModelParameterNames = fieldnames (get_param('vdp','ObjectParameters'));
GlobalParameterNames = setdiff (RootParameterNames,ModelParameterNames)
GlobalParameterNames =
          'AutoSaveOptions'
          'CacheFolder'
          'CallbackTracing'
          'CharacterEncoding'
                 . . .
          'CurrentSystem'

Get the value of a global parameter. (If you enter a model parameter, you get the default value of the parameter, not the current value)

GlobalParameterValue = get_param(0,'CurrentSystem')
GlobalParameterValue =
          vdp

Get Model Parameter Names and Values

Get a list of model parameters (returned in a structure) for the vdp model .

load_system('vdp')
ModelParameterNames = get_param('vdp','ObjectParameters')
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 the Version model parameter for the vdp model.

ModelParameterValue = get_param('vdp','Version')
ModelParameterValue =
          8.3000

Get Block Parameter Names and Values

Get a list of block paths and names (returned in a cell array) for the vdp model.

load_system('vdp')
BlockPaths = find_system('vdp','Type','Block')
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 (returned in a structure) for the Fcn block.

BlockDialogParameters = get_param('vdp/Fcn','DialogParameters')
BlockDialogParameters = 
                Expr: [1x1 struct]
          SampleTime: [1x1 struct]

Get the value for the Expr block parameter.

BlockParameterValue = get_param('vdp/Fcn','Expr')
BlockParameterValue =
    1 - u*u

Display Block Types for all Blocks in a Model

Get a list of block paths and names (returned in a cell array) for the vdp model.

load_system('vdp')
BlockPaths = find_system('vdp','Type','Block')
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 the BlockType parameter for each of the blocks in the vdp model.

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

Input Arguments

expand all

Model — Name of a modelstring | handle

Name of a Simulink model, specified as a string or handle to a model object.

GlobalParam — Parameter defined during a Simulink sessionstring

Parameter defined during a Simulink session, specified as a string. Parameters include Simulink Editor preferences and Simulink Coder™ parameters.

ModelParam — Parameter saved with a Simulink modelstring

Parameter saved with a Simulink model, specified as a string. Parameters include Simulink model configuration parameters, Simulink Coder parameters, and Simulink Code Inspector parameters.

Block — Path and name of a Simulink blockstring | cell array of strings

Path and name of a Simulink block, specified as a string or cell array with block paths and names.

BlockParam — Name of a block parameterstring

Name of a block parameter, specified as a string. These parameters define how the block displays in the Simulink Editor, define a mask for the block, specify how the block is simulated within a model, and include the block dialog parameters.

BlockDialogParam — Name of a block dialog box parameterstring

Name of a block dialog box parameter, specified as a string. These parameters are specific to the type of block, i.e., these are the parameters you can specify in the block dialog box.

Output Arguments

expand all

RootParamNames — Names of root parametersstructure array of strings

Names of root parameters in a structure array. Each parameter name is a field in the structure. Each parameter field is a structure having these fields:

  • Type — Parameter type values are: 'boolean', 'string', 'int', 'real', 'point', 'rectangle', 'matrix', 'enum', 'ports', or 'list'

  • Enum — Cell array of enumeration string values that applies only to 'enum' parameter types

  • Attributes — Cell array of strings defining the attributes of the parameter. Values are: 'read-write', 'read-only', 'read-only-if-compiled', 'write-only', 'dont-eval', 'always-save', 'never-save', 'nondirty', or 'simulation'

GlobalParamValue — Value of global parametervalue

Value of global parameter.

ModelParamNames — Names of model parametersstructure array of strings

Names of model parameters.

ModelParamValue — Value of model parametervalue

Value of model parameter.

ModelParamDefaultValue — Default value of model parametervalue

Default value of model parameter.

BlockParamNames — Names of block parametersstructure array of strings

Names of block parameters.

BlockDialogParamNames — Names of block dialog box parametersstructure array of strings

Names of block dialog box parameters.

BlockParamValue — Value of a block parametervalue

Value of a block parameter.

BlockDialogParamValue — Value of a block dialog box parametervalue | cell array of values

Value of a block dialog box parameter or cell array with parameter values.

Was this topic helpful?