Main Content

ParameterSet

Real-time application parameter set

Description

A ParameterSet object represents the contents of a parameter set file imported from a real-time application that is loaded on a target computer and provides access to methods and properties related to the parameter set file.

The object provides access to methods and properties that:

  • Save parameters from a real-time application to a parameter set file.

  • Import parameter set file data into a ParameterSet object.

  • Tune parameters in the real-time application by using the ParameterSet object.

  • Apply the tuned parameters from the real-time application to the model.

Function names are case-sensitive. Type the entire name. Property names are not case-sensitive. You do not need to type the entire name if the characters you type are unique for the property.

Creation

Create a ParameterSet object by using the importParamSet command. After you create and connect to the Target object and load the real-time application on the target computer, you import the parameter set information from the loaded application into a ParameterSet object. This example creates and connects to Target object tg, loads a real-time application, creates a parameter set file, and imports parameter set information into a ParameterSet object myParamSet on the development computer.

mdlName = 'slrt_ex_osc_outport';
slbuild(mdlName);
tg = slrealtime('TargetPC1');
connect(tg);
load(tg,mdlName);
paramSetName = 'myParamSet';
saveParamSet(tg,paramSetName);
myParamSet = importParamSet(tg,paramSetName);

Properties

expand all

The filename property holds the parameter set file name on the target computer. This property is set by using the saveParamSet method.

Example: 'myParamSet'

Object Functions

deleteDeletes a ParameterSet object
explorerOpen Parameter Explorer and view Parameter Set
exportToModelExport values from ParameterSet object to model
setSet a parameter value in a ParameterSet object
syncWithAppSync model parameters to real-time application parameters

Examples

collapse all

The ParameterSet object and methods let you tune parameters in the real-time application and apply the tuned parameters to the model. For a flowchart of this workflow, see Save and Reload Parameters by Using the MATLAB Language.

Build the model and load the real-time application.

mdlName = 'slrt_ex_osc_outport';
slbuild(mdlName);
tg = slrealtime('TargetPC1');
load(tg,mdlName);

Save the parameter set to a file.

paramSetName = 'outportTypes';
saveParamSet(tg,paramSetName);

Import the parameter set into a ParameterSet object on the development computer.

myParamSet = importParamSet(tg,paramSetName);

To view or edit the parameters, open the ParameterSet object in the Simulink Real-Time Parameter Explorer UI.

explorer(myParamSet);

After tuning the parameters, export the modified parameter set to the parameter set file on the target computer and load the parameters into the real-time application.

exportParamSet(tg,myParamSet);
loadParamSet(tg,myParamSet.filename);

To synchronize the parameter name-value pairs and synchronize the model checksum saved in the parameter set object with the real-time application, use the syncWithApp command.

syncWithApp(myParamSet,mdlName);

To set a parameter value in the ParameterSet object programmatically instead of using the Simulink Real-Time Parameter Explorer UI, use the set command.

set(myParamSet,'slrt_ex_osc_outport/Signal Generator/Amplitude',2);

To delete the contents of a ParameterSet object, use the delete command.

delete(myParamSet);
Introduced in R2021a