Commit 15bdd649 authored by kinuthia's avatar kinuthia
Browse files

add missing matlab functions

parent 8e5f037d
Loading
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
function [floatv, integer, Q] = toInt16(float)
maxV = max(max(abs(float)));
Q = 15;
for i = 15:-1:0
    if maxV * 2^i <= 2^15
        Q=i;
        break
    end
end
integer = floor(float * 2^Q);
floatv = integer * 2^-Q;
end
+12 −0
Original line number Diff line number Diff line
function [floatv, integer, Q] = toInt32(float)
maxV = max(max(abs(float)));
Q = 31;
for i = 31:-1:0
    if maxV * 2^i <= 2^31
        Q=i;
        break
    end
end
integer = floor(float * 2^Q);
floatv = integer * 2^-Q;
end