How to convert binary stream of length 1*524288 to decimal string of length 1*65536?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Veera Kalyani S
le 7 Jan 2017
Commenté : Veera Kalyani S
le 11 Jan 2017
There is a need to group 8 bits in the binary stream of 1*524288 to make a decimal string..how to do this using matlab?
4 commentaires
Image Analyst
le 7 Jan 2017
Can you give a short example of how you are getting a longer decimal string from the shorter binary string, like '1101001' goes to '123456787654627838' or something?
Réponse acceptée
Stephen23
le 8 Jan 2017
Modifié(e) : Stephen23
le 8 Jan 2017
bin2dec probably does most of what you want:
>> bin2dec(reshape('0000000100000010',8,[]).')
ans =
1
2
3 commentaires
Stephen23
le 9 Jan 2017
Modifié(e) : Stephen23
le 9 Jan 2017
You seem to have put my code inside a loop, and then inside that loop you access one character of the string at a time, like this:
k(i)
What do you expect to do with one character at a time?
My answer works perfectly for a string with size 1*524288, and it does not need any loops:
>> str = char(randi(48:49,1,524288));
>> vec = bin2dec(reshape(str,8,[]).')
vec =
233
164
146
110
134
162
238
203
etc
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Functions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!