set rounding mode in stateflow

19 ビュー (過去 30 日間)
진회
진회 2024 年 4 月 8 日
コメント済み: Manikanta Aditya 2024 年 4 月 8 日
i try to calculate in stateflow with action language C
input_a => fixdt(1,16,1e-3,0)
input_b => fixdt(1,32,1e-7,0)
output_c = > fixdt(1,16,1e-3,0)
output_c = input_a + input_b
In this case, the rounding mode of ouput_c is always floor in stateflow chart.
But, i want to make the ouput with round or nearest in chart.
Is there any option to set rounding mode as round or nearest with action language C in stateflow chart?
  3 件のコメント
진회
진회 2024 年 4 月 8 日
thank you for comment.
that is usefull technique!
Manikanta Aditya
Manikanta Aditya 2024 年 4 月 8 日
Cool.

サインインしてコメントする。

回答 (1 件)

Angelo Yeo
Angelo Yeo 2024 年 4 月 8 日
(1) "In this case, the rounding mode of ouput_c is always floor in stateflow chart."
>> Not true. It depends on conversion mode: offline or online conversion.
Offline conversions initialize data during code generation. Offline conversions are designed to maximize accuracy. These conversions round the resulting quantized integer to its nearest integer value.
Online conversions perform casting operations during run time. Online conversions are designed to maximize computational efficiency. Instead of rounding Q to its nearest integer, online conversions round to the floor (except for division, which can round to 0, depending on the C compiler).
(2) "Is there any option to set rounding mode as round or nearest with action language C in stateflow chart?"
>> No, as long as you use Charts for run time.
(3) My answers are quoted rom the doc below. See the doc for more information.
(4) If you think this design does not meet your requirement, please reach out to technical support team in order to submit an enhancement request.
  1 件のコメント
진회
진회 2024 年 4 月 8 日
thank you for your comment!
i will try your recomendation by following you contents.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDecision Logic についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by