function value = dec2tc(dec, N)
value = dec2bin(mod((dec),2^N),N);
end
function value = tc2dec(bin,N)
val = bin2dec(bin);
y = sign(2^(N-1)-val)*(2^(N-1)-abs(2^(N-1)-val));
if ((y == 0) && (val ~= 0))
value = -val;
else
value = y;
end
end
Handy for 16 bit numbers, but not anything else. It even takes an input for what appears to be the number of bits (i.e. other than 16), but never utilizes it. Good start on a function that could be far more useful.