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

조회 수: 27 (최근 30일)
How can I identify whether a block parameter is tunable or nontunable during simulation?

채택된 답변

MathWorks Support Team
MathWorks Support Team 2025년 3월 11일
편집: MathWorks Support Team 2025년 3월 11일
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 Simulink documentation for further information on parameter tunability during simulation.
There are two options to determine if a block or mask parameter is tunable or not:
Option 1: Using the 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.
Option 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 attribute 'read-only-if-compiled' indicates that for the Discrete Transfer Fcn block:
  • The ‘Numerator’ parameter is tunable
  • The ‘SampleTime’ parameter is not tunable.
.
Important Notes for Code Generation workflows:
Parameters that are tunable during Simulink simulation can appear as non-tunable inlined parameters in the generated code. If you simulate your model by using SIL, PIL, External Mode, and/or Simulink Real-Time simulation, parameter tunability during the simulation and between simulation runs can depend on your code generation settings.
To ensure parameter tunability in the generated code, set the model configuration parameter Default parameter behavior to 'Tunable'. 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.
Furthermore, there are code generation-specific limitations that can render parameters non-tunable in the generated code. For example, using a mask parameter in mask initialization code, or using those parameters in certain expressions, can render a parameter non-tunable. For more information, see Limitations for Block Parameter Tunability in Generated Code.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Model, Block, and Port Callbacks에 대해 자세히 알아보기

제품


릴리스

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by