%% Convert Hexadecimal Number to Binary
% Starting in R2019b, you can write numbers as binary or hexadecimal literals, using the 0b and 0x prefixes. MATLAB® interprets and stores these literals as ordinary numbers, which the dec2bin function can convert to character arrays representing binary values.
% Write a number as a hexadecimal literal. It is stored as an unsigned integer with an appropriate size.

h = 0xFF

%
% Convert it to a character vector using dec2bin.

binStr = dec2bin(h)

%
% As an alternative, in any version of MATLAB, you can represent the hexadecimal number by a character vector, and convert it using the hex2dec and dec2bin functions together. When using hex2dec, do not write the 0x prefix.

hexStr = 'FF';
D = hex2dec(hexStr)

%

binStr = dec2bin(D)

%
% Copyright 2019 The MathWorks, Inc.