# MATLAB: How to convert a string to binary and then from the binary back to string

string to binary and back

how to convert a string to binary and then from the binary back to string
s = 'Mary had a little lamb';binary = dec2bin(s);str = bin2dec(binary)
but str i obtained is not string… how to get the string back… also, when i do above i get binary as char variable…
binary =100110111000011110010111100101000001101000110000111001000100000
is it possible, to get is as a vector, with double datatype and i should be able to get that back as string…
binary =1  1  0  1  0  0  0  0  1  0

• binary = reshape(dec2bin(s, 8).'-'0',1,[])str = char(bin2dec(reshape(char(binary+'0'), 8,[]).'))