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

16 visualizaciones (últimos 30 días)

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 19 de Jun. de 2023
Editada: MathWorks Support Team el 19 de Jun. de 2023
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:
Refer to the documentation link below for further information on tunable parameters and important limitations:
Approach 1: Via Block dialog
One 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.
Approach 2: Using the MATLAB command line:
Querying the block parameters for their attributes is another 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.
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.

Más respuestas (0)

Productos


Versión

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by