필터 지우기
필터 지우기

how can I know which data types I need precisely?

조회 수: 2 (최근 30일)
SimTec
SimTec 2021년 6월 24일
답변: vidyesh 2024년 4월 12일
I have simulated a PI controller in simulink in double precision format, as the showed picture:
and then when I change the addition and multiplication to single precision 32bit, I got a slight error around 100mv difference between the target and the output.
again, I have implemented the controller in DSP in C code and the there I used single precision. so my question is how to know if the single precision is enough or the double precision is needed? I meanfor me when I look at the single precision seems enough in term of precision but the outcome is slighlty difference also in DSP compared to double precision in Simulink.
I know it is a stupid question, I looked on the net the difference and it shows not so much on which one to choose.

답변 (1개)

vidyesh
vidyesh 2024년 4월 12일
Hi SimTec,
Your question touches on the trade off between accuracy and computational cost of a system. Single precision, with its 7 decimal digits of precision, generally suffices for applications where slight errors (like a few hundred millivolts difference) are acceptable. It's faster and more resource-efficient, making it a good fit for real-time or embedded systems. Double precision, offering about 15 decimal digits of precision, is better suited for scenarios demanding high accuracy or where errors can accumulate. Ultimately, the choice hinges on the system's specific error tolerance, performance requirements, and resource constraints.
Depending on the required level of accuracy, the precision of the variables can be decided mathematically or through trial and error, depending on the system's complexity.
Refer to the below pages for more information on how to control the precision of variables:
Hope this helps.

카테고리

Help CenterFile Exchange에서 Signal Attributes and Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by