MATLAB: I want to convert string to binary equivalent and binary to string

MATLAB

I want to convert the string to binary equivalent and then again convert the string to binary. I got the code for this
String='This is your sample hidden string.';
binar=reshape(dec2bin(String,8).',1,[])
reconver_str = char(bin2dec(reshape(char(binar+'0'), 8,[]).'))
but i getting the error
Error using bin2dec (line 55)
Binary string may consist only of characters 0 and 1
Error in convstrtobin (line 3)
reconver_str = char(bin2dec(reshape(char(binar+'0'), 8,[]).'))
can anyone please help me how to correct this error.

Best Answer

You forgot to subtract '0'
binar=reshape(dec2bin(String,8).',1,[]) - '0';