getparamid

Parameter index from parameter hierarchical name

Description

example

parameter_index = getparamid(target_object, parameter_block_name, parameter_name) returns the parameter-list index of a block parameter. The function searches the parameter list by the path to the block and the parameter name.

Enter for parameter_block_name the mangled name that the Simulink® Coder™ software uses for code generation. You can determine the mangled name as follows:

  • If you do not have special characters in your model, use the gcb function.

  • If the blocks of interest have special characters, retrieve the mangled name using tg.showparam = 'on'.

    For example, if carriage return '\n' is part of the block path, the mangled name returns with carriage returns replaced by spaces.

Enter the names in full. The names are case-sensitive.

example

parameter_index = getparamid(target_object, '', parameter_name) returns the parameter-list index of a global parameter that provides the value for a block parameter. The function searches the parameter list by the MATLAB® variable name. The name is case-sensitive.

For the block name argument, enter the empty character vector ('') or empty string scalar ("").

Examples

collapse all

Get the value of block parameter 'Amplitude' of block 'Signal Generator'

tg = slrt;
pid = getparamid(tg, 'Signal Generator', 'Amplitude');
getparam(tg, pid)
ans =

     4

Get the value of MATLAB variable 'Freq'

tg = slrt;
pid = getparamid(tg, '', 'Freq');
getparam(tg, pid)
ans =

     20

Input Arguments

collapse all

Object that represents the target computer. Before calling this function, make sure that you start the target computer with the Simulink Real-Time™ kernel and apply the required Ethernet link settings.

Example: tg

The empty character vector ('') or empty string scalar ("") as a block name marks a global parameter that provides the value for a block parameter. The MATLAB variable is not associated with a particular block.

Example: 'Gain1', ''

The parameter can designate either a block parameter or a global parameter that provides the value for a block parameter. To be accessible via parameter name, the block parameter or MATLAB variable must be observable.

Note

Simulink Real-Time does not support parameters of multiword data types.

Example: 'Gain', 'oscp.G1', 'oscp', 'G2'

Output Arguments

collapse all

The parameter index can mark either a block parameter or a global parameter that provides the value for a block parameter. To be accessible via parameter index, the block parameter or MATLAB variable must be observable.

To access a parameter index, type tg.ShowParameters = 'on' in the Command Window, and count lines starting with 0.

Note

Parameter access by parameter index will be removed in a future release. Access parameters by parameter name instead.

Example: 0, 1

Introduced in R2014a