How to get the correct precision of fraction from hdlcoder?
Infos
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Afficher commentaires plus anciens
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 commentaires
Walter Roberson
le 1 Fév 2018
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
le 1 Fév 2018
Réponses (0)
Cette question est clôturée.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!