%% Specify Minimum Number of Digits
% Specify the minimum number of hexadecimal digits that dec2hex returns. If you specify more digits than are required, then dec2hex pads the output.

D = 1023;
hexStr = dec2hex(D,6)

%
% If you specify fewer digits, then dec2hex still returns as many hexadecimal digits as required to represent the input number.

hexStr = dec2hex(D,1)

% Copyright 2019-2020 The MathWorks, Inc.