'Generated code will not preserve the expression' warnings

10 visualizaciones (últimos 30 días)
Jonas
Jonas el 1 de Oct. de 2021
Comentada: Jonas el 4 de Jul. de 2022
Warning 1
I am getting the following warning on a Simulink.Parameter object stored in my Data Dictionary:
Parameter object 'Value' property uses an expression 'ADC_V/single(ADC_COUNT)' involving division operator. Under this condition, generated code will not preserve the expression.
This Simulink.Parameter object is indeed defined by an expression in the value field:
=ADC_V/single(ADC_COUNT)
Those variables used in the expression are other Simulink.Parameter objects in the same Data Dictionary structure.
Warning 2
Similarly, I am getting the following warning on another Simulink.Parameter:
Expression '[IUVW_GAIN_MATRIX_REV_A IUVW_GAIN_MATRIX_REV_A]' involves variable 'IUVW_GAIN_MATRIX_REV_A', whose value is nonscalar. Due to the nonscalar value, the expression will not be preserved in the generated code.
where those variables are multi-dimensional Simulink.Parameter objects (3x3 matrices).
Question
I do not want to preserve the expression in my code, I just want to preserve the expression in my Data Dictionary only.
How can I surpress these warnings?
  2 comentarios
yang ji
yang ji el 1 de Jul. de 2022
I have the same problems,do you solve it?
Jonas
Jonas el 4 de Jul. de 2022
I still did not manage to solve Warning 2.
I did solve Warning 1. The reason is the following. The variable 'ADC_V' is a Simulink.Parameter of type single. The variable 'ADC_COUNT' is a Simulink.Parameter of type uint16. By casting the uint16 to a single value the division can be made, but due to single precision representation limits, the diagnostic viewer gives the warning that the result of the division will not exactly match the data type single.
The warning is avoided by writing:
=single(ADC_V/single(ADC_COUNT))
as a value for the Parameter. This way, you force the division to fit into a single data type and it cannot complain.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Deployment, Integration, and Supported Hardware en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by