سؤال

i have a binary stream,

message_1 = '0100100001000101010011000100110001001111' 

Now i want to convert this binary stream into its equivalent characters i.e. the result should be 'HELLO'. Please help me

هل كانت مفيدة؟

المحلول

Use this -

char(bin2dec(reshape(message_1,8,[])'))'

نصائح أخرى

Convert from characters to numbers (-'0'); arrange the bits in groups of 8 (reshape); convert each group into a number between 0 and 255 (sum(bsxfun(@times, ...))); and from that to char:

>> char(sum(bsxfun(@times, reshape(message_1-'0',8,[]), 2.^(7:-1:0).')))
ans =
HELLO
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top