After entering a binary bit sequence in an input dialog box, I'm having issues when I try to convert it to a numeric value. When the str2num function is used, the leading zeros are erased. Below is my code:
prompt = {'Enter bit sequence (max 8 bits):'};ititle = 'Input';dims = [1 35];temp1 = inputdlg(prompt,ititle,dims);temp2 = str2num(temp1{1});bit_sequence = str2num(num2str(temp2).');disp(bit_sequence)
If the input is 0110, the output is
110
I would like to know how to keep the leading zero.
Best Answer