Cast to double in embedded coder

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 件のコメント

Raghava S N
Raghava S N 2025 年 4 月 4 日
編集済み: Raghava S N 2025 年 4 月 4 日
Could you attach the dependent scripts and files being used by the model? That will help in accurately debugging this issue by reproducing it.
In the mean time, please refer to this documentation link, which describes Casting Modes; these parameters enable you to control data type casts in the generated code - https://www.mathworks.com/help/ecoder/ug/control-data-type-casts-in-generated-code.html
Best,
Raghava
Sahas
Sahas 2025 年 4 月 7 日
Please provide the additional files to reproduce the model.
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 日

0 投票

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.

カテゴリ

ヘルプ センター および File ExchangeDeployment, Integration, and Supported Hardware についてさらに検索

製品

リリース

R2024b

質問済み:

2025 年 4 月 2 日

回答済み:

2025 年 4 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by