Commit 2b74f8e5 authored by Lucas Russo's avatar Lucas Russo

scripts/matlab/*: add function to omit binary overflow false-positives

This function is useful to omit false positives
when detecting non consecutives samples, such
as the wraparound from 32767 to -32768, which
are consecutive samples to the binary point of view.
parent 5981696a
function x = omit_wraparound(a, nc_idx, mode, num_bits)
if strcmp (mode, "twoscomplement")
limit_bot = -2^(num_bits-1);
limit_up = 2^(num_bits-1)-1;
elseif strcmp (mode, "offsetbinary")
limit_bot = 0;
limit_up = 2^(num_bits)-1;
else
error ("mode is not valid! Supported modes are \"twoscomplement\" and \"offsetbinary\"");
end
x = [];
for n = 1:2:size(nc_idx,1)*size(nc_idx,2)
if a(nc_idx(n)) != limit_up || a(nc_idx(n+1)) != limit_bot
x = [x, [nc_idx(n);nc_idx(n+1)]];
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment