Here is how to convert from decimal numbers to binary 2’s complement in Matlab:

binary_value = dec2bin(mod((dec_value),2^N),N);

where N is the bit-width of binary number.