Borrar filtros
Borrar filtros

How to decrease the precision of an arithmetic operation

1 visualización (últimos 30 días)
Alessandro Russo
Alessandro Russo el 26 de En. de 2017
Comentada: Walter Roberson el 27 de En. de 2017
Hi all.
I have a question about the precision used by Matlab in arithmetic operations. I have an array of data acquired by my acquisition system, with an ADC on 12 bit. When i load the data in Matlab, all the values are loaded as "short", that is to say on 16 bit, and the nonzero digits are only the first 8 decimal numbers, then there are zeros to fill all the 16 bits. The problem is that i want to do some operations on these values, like removing the mean and filter them; when i remove the mean, calculating it with the function "mean" and then subctracting it from the array, i get 15 nonzero decimal numbers, because the mean i get from the function is expressed on 15 decimal digits. This makes all the variables from this step on, bigger. How can i get ALL the operations like mean removal, filtering and everything else take only 8 decimal digits, since i don't need higher precision and i prefer to save space? Thanks in advance.

Respuestas (1)

Walter Roberson
Walter Roberson el 26 de En. de 2017
When you call mean() you can pass the option 'native' to have the mean be the same datatype as the input.
Some of the filtering routines only work on floating point; it would depend on which one you used.
  2 comentarios
Alessandro Russo
Alessandro Russo el 26 de En. de 2017
Editada: Alessandro Russo el 26 de En. de 2017
I use "filtfilt" to apply butterworth filtering. There is no other possibility? I mean something to "truncate" the significant digits?
Walter Roberson
Walter Roberson el 27 de En. de 2017
filtfilt() only accepts doubles.
If the values you get back are in the range 0 to 65535, then you can divide them by 16 to get values in the range 0 to 4095.
Once you have values in the range 0 to 4095, if you want to keep them in that range after filtering, you can use floor() on the results of the filtering.
(Depending on the filtering you do, you could potentially end up with a little gain, so the values might not remain strictly in that range.)

Iniciar sesión para comentar.

Categorías

Más información sobre Matched Filter and Ambiguity Function 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!

Translated by