Prevent rounding of a number.
Mostrar comentarios más antiguos
I'm using the following code to check and correct extreme values in a matrix. The maximum value can not be 1, it must be one quantisable segment below 1. In this example bitDepth is 16 and so maxValue should calculate to be the number commented after it. However, MATLAB just rounds maxValue up to 1 and so my code is failing further along. How can I make MATLAB keep the accuracy of this number?
%Check for clipping
maxValue = 1-(1/2^bitDepth); %0.99998474121093744448884876;
sampleValue = inputBuffer(currentFrameSample, currentChannel);
if sampleValue > maxValue
inputBuffer(currentFrameSample, currentChannel) = maxValue;
elseif sampleValue < (-1.0)
inputBuffer(currentFrameSample, currentChannel) = (-1.0);
end
Thanks in advance, Matt.
Respuesta aceptada
Más respuestas (1)
Matt
el 15 de Nov. de 2012
0 votos
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!