You need a combination of dec2bin and str2num:
First, convert your input into a binary representation:
WORD = 'hello';
WORD_BINARY = dec2bin(WORD,7) % The 7 gives the number of bits
This results in:
WORD_BINARY =
1101000
1100101
1101100
1101100
1101111
This is a string, which now has to be turned into a vector:
for i=1:size(WORD_BINARY,1)
for j=1:size(WORD_BINARY,2)
WORD_OUTPUT(1,(i-1)*size(WORD_BINARY,2)+j) = str2num(WORD_BINARY(i,j))
end
end
WORD_OUTPUT in this case is a <1x40> vector, starting with:
WORD_OUTPUT =
[ 1 1 0 1 0 ...
Edit
If you do not want two for loops, you can use reshape first (but be aware, that reshape orders by column, not row):
WORD = 'hello';
WORD_BINARY = reshape(dec2bin(WORD,7)',1,[]);
% note the <'> after the dec2bin, to transpose the matrix
for j=1:size(WORD_BINARY,2)
WORD_OUTPUT(1,j) = str2num(WORD_BINARY(1,j));
end