Prevent rounding of a number.
5 views (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
More Answers (1)
See Also
Categories
Find more on 3-D Scene Control in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!