Cast to double in embedded coder
5 views (last 30 days)
Show older comments
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 Comments
Sahas
on 10 Apr 2025
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.
Answers (1)
Mark McBroom
on 12 Apr 2025
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.
0 Comments
See Also
Categories
Find more on Deployment, Integration, and Supported Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!