Hi all,
I am mew in matlab and I have to read a text and then make a vector with the binary value of their chars.

For example :
text = 'pr'
ascii = 1010000
1110010

I want to make a vector like that -->
[1;0;1;0;0;0;0;1;1;1;0;0;1;0]


My code is

function bits_vector = textbin(text)

text_ascii = uint8(text);
num = length(text_ascii)

bits_matrix = dec2bin(text_ascii,7)-'0';

len_vector = num*8

bits_vector = zeros(len_vector,1)

for i=1:len_vector
    bits_vector(i:(i+7)) = bits_matrix(i,:)
    i=i+8;
end

Any help ? Please

Thank you

it is hard

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.