MATLAB Answers


How do I decode a binary string that is 1X104 characters long that is written in ASCII?

Asked by Karen.k
on 5 Nov 2012

string: 00001011000110110111100101111000011110000111101101101000000110100000011100001011000000110001101101101001

This string is suppose to contain a message, but everytime I try to decode it I get abstract letters and signs. Help?

  1 Comment

Jan Simon
on 5 Nov 2012

Please do not post 2 questions about the same topic. See It would be more helpful for the ones, who want to answer, if you answer question for clarifications and add new information by editing the original question. Thanks.

If you have any methods to decode this message, I strongly assume, that you have more information than you show. So please post at least the failing methods.



No products are associated with this question.

2 Answers

Answer by Matt Fig
on 5 Nov 2012

How is the message stored? I.e., how many bits per letter, etc. It might help if you show how that string was generated from the ascii message.


Answer by Jan Simon
on 5 Nov 2012

Let's assume, that the code uses the same number of bits per character, so it it not run-length or Huffmann encoded. 104 has the factors 2,2,2,13, such that you have either 2, 4, 8, 13 or 26 bits per character, but even 104 bits are possible. E.g. this could be the ISBN number of a printed version of the Gettysburg address...

When We assume 8 bits, and the code is stored as sequential stream, we get these double values:

11, 27, 121, 120, 120, 123, 104, 26, 7, 11, 3, 27, 105

These are obviously not ASCII codes, because all values below 32 are non-printables like control characters. The numbers do not represent a simple character translation like a=1, b=2, ... A=27, B=28, because the value above 52 would be meaningless.

With 4 bits per character you can represent only 16 different values. Assuming the translation a=0,b=1,... you get:


This is not a word in a language I know.

  1 Comment

8-bit at a time implementation:


This will give char([11,27,121 (etc)]) as described in Jan's answer.

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!