954,557 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Matlab problem

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

bufospro
Junior Poster
143 posts since May 2007
Reputation Points: 14
Solved Threads: 0
 

it is hard

aabbddlah
Newbie Poster
3 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You