Wrong conversion from double to fixed point

조회 수: 13(최근 30일)
Marco Bottani
Marco Bottani 2019년 6월 21일
답변: MathWorks Fixed Point Team 2020년 1월 13일
Hello,
I'm trying to convert a project developed in double data type into a fixed point data type project, but I'm loosing to much precision.
Using the double data type my output speed is expressed in RPM, but using fixed point data type I need to have it as fixdt(1,16,15) using an input value (delta_angle) coming from the outside ad fixdt(1,16,12).
Please see the attached models.
Do you have any suggestion to convert properly the data?
Thanks in advance for the help.

답변(2개)

MathWorks Fixed Point Team
MathWorks Fixed Point Team 2020년 1월 13일
Hello, you can try to use any of the Fixed-Point designer workflows to achieve this task.
Please find attached a script that uses the fixed-point optimziation feature to help with the conversion. With this workflow you only need to set the allowable level of error in your system requirements using the "addTolerance" API. With this information, fxpopt will try to convert your system automatically. Please notice that the attached model is the one I got running on my local PC (on a 19b version of MATLAB).
Alternativelly you can use the fixed-point tool to go though the steps of conversion manually.
You can find some introductory videos and exmaples on these links.
Using Fixed-Point Tool:
Fixed-Point Optimization:

Xu Liu
Xu Liu 2019년 7월 10일
hi Marco
When you convert data of longer words to data types of smaller words, the loss of precision is inevitable.
If your processor has a 32-bit floating point kernel (as some processors currently do), it is recommended that you use single instead of double

Community Treasure Hunt

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

Start Hunting!

Translated by