MATLAB: How to add leading zeros to a number in Hex format

hexadecimalleading zeroMATLABzero padding

I'm trying to convert some binaries to the hexadecimal format. but I need Matlab to display zeros before the hex numbers.
for example:
if the input is '00001111' the output should display '0F'
if the input is '0000000000001011' the output should be '000B' and so on.
Thanks a lot for your help!

Best Answer

s = '0000000000001011';
sprintf('%0*X', ceil(length(s)/4), bin2dec(s))