Main Content

Simulink.HMI.ParamSourceInfo

Information about Dashboard block variable and parameter connections

Description

Use a Simulink.HMI.ParamSourceInfo object to connect a Dashboard block to a variable or parameter programmatically using the set_param function. The get_param function returns a Simulink.HMI.ParamSourceInfo object when you use the function to query the connection information for a Dashboard block connected to a variable or parameter.

The Simulink.HMI.ParamSourceInfo object contains four properties. Some of the properties apply to connecting Dashboard blocks to parameters, and some apply for connecting Dashboard blocks to variables. Not all fields have a value for a connection because a given Dashboard block connects to either a parameter or a variable.

Creation

Description

example

paramSourceInfo = Simulink.HMI.ParamSourceInfo creates the empty Simulink.HMI.ParamSourceInfo object, paramSourceInfo.

Properties

expand all

Simulink.BlockPath object for the block associated with the parameter or variable. You can create a Simulink.BlockPath object for a block by passing a character array describing the path to Simulink.BlockPath. You can get a character array describing the block path for a selected block using the gcb function.

Example: Simulink.BlockPath('vdp/Mu')

Name of the connected tunable block parameter, specified as a character array. A Simulink.HMI.ParamSourceInfo object connected to a variable does not have a value for the ParamName property.

Example: Gain

Name of the connected variable, specified as a character array. A Simulink.HMI.ParamSourceInfo object connected to a tunable parameter does not have a value for the VarName property.

Example: Mu

Element of nonscalar variable or parameter value to connect, specified as a character array.

When the value of the variable or parameter you want to tune using a dashboard block is nonscalar, use the Element property to specify the scalar element of the nonscalar value that you want to tune. To connect to a scalar element in a vector or matrix, specify the element index. To connect to an element of a bus or structure, specify the element in the context of the bus or structure hierarchy by using dots to indicate different levels in the hierarchy, and omit the top level. The value of the VarName property or the ParamName property specifies the top level.

Example: 3 connects the block to the third element of the variable specified by the VarName property or the parameter specified by the ParamName property.

Example: (3,2) connects the block to the element in the third row and second column of the variable specified by the VarName property or the parameter specified by the ParamName property.

Example: a.b connects the block to element b of the nested structure or bus a within the value of the variable specified by the VarName property or the parameter specified by the ParamName property.

Source workspace for the connected variable, specified as a character array. The source workspace can be the base workspace, model workspace, or a data dictionary. When the source workspace is a data dictionary, the WksType property value is the file path for the data dictionary, specified as a character array. A Simulink.HMI.ParamSourceInfo object connected to a tunable parameter does not have a value for the WksType property.

Example: 'modelData.sldd'

Examples

collapse all

This example shows how to programmatically add Dashboard blocks to a model and connect them to elements in the model. The example adds a Dashboard Scope block and a Slider block to the vdp model and connects and configures the blocks.

Add Blocks

Use the add_block function to add a Dashboard Scope block and a Slider block to the vdp model. This example also specifies the position of the blocks.

mdl = "vdp";
open_system(mdl)

scopePos =  [750 85 990 295];
sliderPos =[765 -5 1005 135];

add_block("simulink_hmi_blocks/Dashboard Scope","vdp/Dashboard Scope",...
    "Position",scopePos)
add_block("simulink_hmi_blocks/Slider","vdp/Slider","Position",sliderPos)

set_param(mdl,"location",[25 25 1133 671]);

Connect the Dashboard Scope Block

Use a cell array of Simulink.HMI.SignalSpecification objects to connect the Dashboard block to the x1 and x2 signals. The Simulink.HMI.SignalSpecification object specifies a connected signal using the block path and port index for the source of the signal. The default value for the OutputPortIndex is 1, so this example does not specify the output port for the x1 and x2 signals.

x1_sigSpec = Simulink.HMI.SignalSpecification;
x1_sigSpec.BlockPath = Simulink.BlockPath("vdp/x1");

x2_sigSpec = Simulink.HMI.SignalSpecification;
x2_sigSpec.BlockPath = Simulink.BlockPath("vdp/x2");

connection_dashboardScope = {x1_sigSpec x2_sigSpec};

Use the set_param function to configure the connected signals for the Dashboard Scope block.

set_param("vdp/Dashboard Scope","Binding",connection_dashboardScope)

Connect and Configure the Slider Block

Use a Simulink.HMI.ParamSourceInfo object and the set_param function to connect the Slider block to the Gain parameter of the Mu block. To connect a parameter, the Simulink.HMI.ParamSourceInfo needs to specify the block path for the block that corresponds to the parameter and the name of the parameter.

slider_param = Simulink.HMI.ParamSourceInfo;
slider_param.BlockPath = Simulink.BlockPath("vdp/Mu");
slider_param.ParamName = 'Gain';

set_param("vdp/Slider","Binding",slider_param)

Configure the scale for the slider for a range of 1 to 10 with a tick mark spacing of 1.

slider_limits = [1 1 10];

set_param("vdp/Slider","Limits",slider_limits)

Version History

Introduced in R2019a