How to get the correct precision of fraction from hdlcoder?
情報
この質問は閉じられています。 編集または回答するには再度開いてください。
古いコメントを表示
Hi,
I came across the difference result value from hdlcoder testbench as the below,
### Begin TestBench generation.
a =
0
a =
0
a =
0
the function code below
%%Function
function result=test(u)
dx=1.71;
u1 = u / 10000;
result= u1/dx ;
end
end
the test code below
clear
clc
u=3000;
[a]=test(u)
u=4;
[a]=test(u)
u=500;
[a]=test(u)
But correct calculation is below,
a =
0.1754
a =
2.3392e-04
a =
0.0292
How do I get value correctly?
2 件のコメント
Walter Roberson
2018 年 2 月 1 日
Change your floating point data type, as Tim said in https://www.mathworks.com/matlabcentral/answers/379928-issue-unexpected-output-from-hdlcoder#answer_302758
satish guruma
2018 年 2 月 1 日
回答 (0 件)
この質問は閉じられています。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!