Cast to double in embedded coder

5 次查看(过去 30 天)
Florian
Florian 2025-4-2
I am seeing cast to double even though all data types are set to float.
Issue occures in stateflow chart with sampletime. Any nice way to disable this pointless conversion.
Prepared reduced dummy example due to IP protection.
Issue occures in Line 203 now.
  4 个评论
Florian
Florian 2025-4-8
Hi,
sorry for the late reply.i updated the question with a reduced dummy example.
BR
Florian
Sahas
Sahas 2025-4-10
I am still unable to see the Liftgate_Control library file to reproduce the issue at my end. The issue seems to be due to an extra type casting in the generated code. I would recommend to see where that logic is there in the stateflow diagram and look for any set datatypes for that variable.

请先登录,再进行评论。

回答(1 个)

Mark McBroom
Mark McBroom 2025-4-12
The default data type for literal constants ( i.e. 1.25) is double. This is causing operations with these contants to be cast to double. YOu need to cast the constants as single: single(1.25).
Thanks.
Mark.

类别

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

产品


版本

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by