how can I know which data types I need precisely?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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.
0 comentarios
Respuestas (1)
vidyesh
el 12 de Abr. de 2024
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.
0 comentarios
Ver también
Categorías
Más información sobre Block Libraries en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!