Main Content

ParameterSet

Real-time application parameter set

Since R2021a

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
compareCompare the parameters in two parameter set objects
deleteDeletes a ParameterSet object
explorerOpen Parameter Explorer and view Parameter Set
exportToModelExport values from ParameterSet object to model
resolveCompare parameter set differences and output resolved parameter set object
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.

  1. Build the model and load the real-time application.

    mdlName = 'slrt_ex_osc_outport';
    slbuild(mdlName);
    tg = slrealtime('TargetPC1');
    load(tg,mdlName);
  2. Save the parameter set to a file.

    paramSetName = 'outportTypes';
    saveParamSet(tg,paramSetName);
  3. Import the parameter set into a ParameterSet object on the development computer.

    myParamSet = importParamSet(tg,paramSetName);
  4. To view or edit the parameters, open the ParameterSet object in the Simulink Real-Time Parameter Explorer UI.

    explorer(myParamSet);
  5. 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);
  6. 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);
  1. To set a parameter value in the ParameterSet object programmatically instead of using the Simulink Real-Time Parameter Explorer UI, use the set command.

  2. set(myParamSet,'slrt_ex_osc_outport/Signal Generator','Amplitude',2);
  1. To delete the contents of a ParameterSet object, use the delete command.

  2. delete(myParamSet);

Version History

Introduced in R2021a