Prevent rounding of a number.
Afficher commentaires plus anciens
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.
Réponse acceptée
Plus de réponses (1)
Matt
le 15 Nov 2012
0 votes
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!