How can I identify whether a block parameter is tunable or nontunable during simulation?

4 views (last 30 days)

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 12 Aug 2022
Edited: MathWorks Support Team on 12 Aug 2022
The dialog parameters of a block can either be tunable or nontunable.  A tunable parameter is a parameter of the block that can change when the simulation is running. The following table summarizes the characteristics:
A notable exception to this rule are the source block parameters, as Simulink does not allow modifying source block parameters through either a dialog or the Model Explorer while a simulation is running. 
Approach 1: Using the MATLAB command line:
Querying the block parameters for their attributes is one way of identifying which parameters of a block are tunable. Here is an example MATLAB code.
% Discrete Tranfer Fcn block dialog parameters
>> paramInfo = get_param(gcb, 'DialogParameters')
paramInfo = 
             NumeratorSource: [1×1 struct]
                   Numerator: [1×1 struct]
           DenominatorSource: [1×1 struct]
Denominator: [1×1 struct]
                   SampleTime: [1×1 struct]
  <...>
% Query Numerator parameter for attributes
>> paramInfo.Numerator
ans = 
        Prompt: 'Numerator coefficients:'
          Type: 'string'
          Enum: {}
    Attributes: {'read-write'  'link-instance'}
% Query SampleTime parameter for attributes
>> paramInfo.SampleTime
ans = 
        Prompt: 'Sample time (-1 for inherited):'
          Type: 'string'
          Enum: {}
    Attributes: {'read-write'  'read-only-if-compiled'  'dont-eval'  'link-instance'}
The block parameter attributes indicate that for the Discrete Transfer Fcn block:
  • The ‘Numerator’ parameter is tunable
  • The ‘SampleTime’ parameter is nontunable.
Approach 2: Via Block dialog
Another way of identifying tunable parameters is via the block dialog.
1. Set the Stop Time of the model to ‘Inf’, so that the simulation runs “forever” while you attempt to tune values in the block dialog.
2. Open the block dialog and attempt to modify all the parameters that are enabled, to identify if they are tunable at run-time.
Important Note:
Parameters that are tunable during simulation can appear as nontunable inlined parameters in the generated code. If you simulate an external program by using SIL, PIL, or External mode simulation, parameter tunability during the simulation and between simulation runs can depend on your code generation settings.
To control parameter tunability in the generated code, you can adjust the code generation settings for a model by using the configuration parameter Default parameter behavior. You can also adjust settings for individual MATLAB variables, Simulink.Parameter objects, and other parameter objects. For more information, see Preserve Variables in Generated Code.
Refer to the documentation link below for further information on tunable parameters:

More Answers (0)

Products


Release

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by