How to reduce the precision of calculations in Matlab?

16 ビュー (過去 30 日間)
Vitaliy  Chistyakov
Vitaliy Chistyakov 2016 年 9 月 16 日
回答済み: Krishna Bindumadhavan 2019 年 9 月 14 日
Hello everyone! I'm writing an algorithm, which is then required to perform in the microcontroller. Usually ADC has 14-bit. Matlab uses a data type of double (64-bit, double -precision) and float (32-bit, single-precision) when using real numbers: -12,234 or 742,0263 etc. How to reduce the precision of calculations in Matlab (maybe use half-precision, but i don't know how), or reduce the bit my variables (e.g. 16-bit) to work with the ADC?
  4 件のコメント
Star Strider
Star Strider 2016 年 9 月 16 日
You can use int16 or uint16, depending on what you need.
Guillaume
Guillaume 2016 年 9 月 16 日
編集済み: Guillaume 2016 年 9 月 16 日
@Stephen, the float type in C languages normally means a 32-bit floating point number and matlab keeps this convention, as 'float' is an accepted precision for fread (and is equivalent to 'single').

サインインしてコメントする。

回答 (3 件)

Guillaume
Guillaume 2016 年 9 月 16 日
If you are really limited to 14 bits for real numbers, then probably you should be used fixed-point numbers instead of floating point numbers. As far as I know matlab does not support half-precission IEEE-754 numbers and anyway these are 16 bits.
  1 件のコメント
Walter Roberson
Walter Roberson 2016 年 9 月 16 日
https://www.mathworks.com/matlabcentral/fileexchange/23173-ieee-754r-half-precision-floating-point-converter
Also there might be some GPU support for half precision.

サインインしてコメントする。


Walter Roberson
Walter Roberson 2016 年 9 月 16 日
When you read a sample from an ADC that uses has 14 bit integer resolution, the result is a 16 bit number that has the value in the most significant 14 bits.

Krishna Bindumadhavan
Krishna Bindumadhavan 2019 年 9 月 14 日
MATLAB now supports half precision floating point numbers via the half precision object, which is available from the fixed point designer toolbox. For more information, please refer to:

製品

Community Treasure Hunt

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

Start Hunting!

Translated by