getparam

Read value of observable parameter in real-time application

Description

example

value = getparam(target_object, parameter_block_name, parameter_name) returns the value of block parameter parameter_name in block parameter_block_name.

example

value = getparam(target_object, parameter_name) returns the value of global parameter parameter_name.

example

value = getparam(target_object, parameter_index) returns the value of the parameter associated with parameter_index.

Examples

collapse all

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

% If you previously built a real-time application from model 
% slrttestmdl, you can load the application on the target 
% computer and get parameter information from the application.
% 
% When working with parameters in the real-time application, it 
% can be helpful to display the parameters that are available 
% in the application by setting the ShowParameters property to 
% 'on' with the command: 
% tg.ShowParameters = 'on' 
% 
tg = slrt;
load(tg, 'slrttestmdl');
getparam(tg, 'Signal Generator', 'Amplitude')
ans =

     4

Get the value of MATLAB® variable 'Freq'.

% To create a variable and assign the Frequency parameter 
% to it, use the block parameter dialog box or commands such as:
% Freq = 20;
% set_param('slrttestmdl/Signal Generator', 'Frequency', 'Freq');
% 
% If you previously created a variable Freq, assigned the Frequency 
% parameter value to Freq, and built a real-time application from model 
% slrttestmdl, you can load the application on the target 
% computer and get parameter information from the application.
%
tg = slrt;
load(tg, 'slrttestmdl')
getparam(tg, 'Freq')
ans =

     20

Get the value of parameter structure 'oscp'.

% To create an array of gain values and assign the gain 
% parameters to its elements, use the block parameter dialog 
% box or commands such as:
% oscp.G0 = 1000000;
% oscp.G1 = 400;
% oscp.G2 = 1000000;
% set_param('slrttestmdl/Gain', 'Gain', 'oscp.G0');
% set_param('slrttestmdl/Gain1', 'Gain', 'oscp.G1');
% set_param('slrttestmdl/Gain2', 'Gain', 'oscp.G2');
% 
% If you previously created a structure array of gain values, 
% assigned the the gain parameter values to the array elements, 
% and built a real-time application from model slrttestmdl, you 
% can load the application on the target computer and get parameter 
% information from the application.
%
tg = slrt;
load(tg, 'slrttestmdl')
getparam(tg, 'oscp')
ans = 

    G0: 1000000
    G1: 400
    G2: 1000000

Get the value of MATLAB variable 'oscp.G2'.

% To create a structure array of gain values and assign the gain 
% parameters to its elements, use the block parameter dialog box 
% or commands such as:
% oscp.G2 = 1000000;
% set_param('slrttestmdl/Gain2', 'Gain', 'oscp.G2');
% 
% If you previously created a structure array of gain values, 
% assigned the the gain parameter values to the array elements, 
% and built a real-time application from model slrttestmdl, you 
% can load the application on the target computer and get parameter 
% information from the application.
%
tg = slrt;
getparam(tg, 'oscp.G2')
ans =

     1000000

Get the parameter index of block parameter 'Gain' of block 'Gain', and then get its value.

% If you previously built a real-time application from model 
% slrttestmdl, you can load the application on the target 
% computer and get parameter information from the application.
% 
tg = slrt;
pid = getparamid(tg, 'Gain', 'Gain');
getparam(tg, pid)
ans =

     1000000

Get the parameter index of MATLAB variable 'G2', and then get its value.

% To create a structure array of gain values and assign the 
% gain parameters to its elements, use the block parameter 
% dialog box or commands such as:
% G2 = 1000000;
% set_param('slrttestmdl/Gain2', 'Gain', 'G2');
% 
% If you previously created a variable G2, assigned the 
% the variable to the Gain2 block gain parameter, and built a 
% real-time application from model slrttestmdl, you can load the 
% application on the target computer and get parameter information 
% from the application.
%
tg = slrt;
pid = getparamid(tg, '', 'G2');
getparam(tg, pid)
ans =

     1000000

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'

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

Output Arguments

collapse all

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

Introduced in R2014a