How to make the gain of the Discrete Derivative block tunable?

8 次查看(过去 30 天)
Are the "Gain Values" of the "Discrete Derivative" and "Discrete Time Integrator" blocks tunable?
In my model these gains are in a structure MDLparam.ki and MDLparam.kd. where MDLparam is a Simulink.Parameter object. When I generate code or run the simulation I get the following warnings and as a result these two gain values do not appear tunable in the generated code:
Warning: Reducing expression 'MDLaram.kd' in parameter field 'gainval' of 'MDL/Discrete Derivative' to its numerical equivalent because this field is marked not tunable. This expression resolves to tunable variables (MDLparam (base workspace)). You will be unable to tune this expression during model execution
Warning: Parameter field 'gainval' of 'MDL/Discrete-Time Integrator' is non-tunable but refers to tunable variables (MDLparam (base workspace))

采纳的回答

Kaustubha Govind
Kaustubha Govind 2012-8-9
It appears that the parameter is not tunable. You can verify this with the commands:
>> dp = get_param('MDL/Discrete Derivative', 'DialogParameters');
>> dp.gainval
ans =
Prompt: 'Gain value:'
Type: 'string'
Enum: {}
Attributes: {'read-write' 'read-only-if-compiled' 'link-instance'}
The attribute 'read-only-if-compiled' indicates that the parameter cannot change once the model has been compiled (ie. during execution).
It is not possible to change how the block itself defines its parameters, so I would recommend following your block with a Gain block. Enter the Gain as 1 in the Discrete blocks, and use the Gain block instead to tune your parameter.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Deployment, Integration, and Supported Hardware 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by