This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

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

Syntax

paramSourceInfo = Simulink.HMI.ParamSourceInfo

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

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 the Dashboard block to elements in the model. The example adds a Dashboard Scope block and a Slider block to the vdp model and shows how to connect and configure 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 for the blocks.

open_system('vdp')

scopePos = [550 140 800 305];
sliderPos = [550 30 800 120];

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

Connect the Dashboard Scope Block

Use a cell array of Simulink.HMI.SignalSpecification object 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)

Introduced in R2019a