# How can I apply a matrix 2*2 to binary digits? [closed]

I want to apply a matrix 2*2 to a binary digits. For example, D and E are two matrices that they apply to a 1 and 0. D --> 1 & E --> 0 binary digits: (1011) --> D.E.D.D

## closed as unclear what you're asking by Daniel Lichtblau, Dr. belisarius, Öskå, MarcoB, ilianAug 6 '15 at 19:00

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Unless I'm reading you wrong, you can use IntegerString[] and StringReplace[] to do what you want. Otherwise, please edit your question to clarify. If you have to, you can write in your native language instead of English. – J. M. is away Aug 6 '15 at 15:25
• Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory Tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. – bbgodfrey Aug 6 '15 at 15:38

## 1 Answer

Use IntegerDigits to produce binary digits of some base 10 integer, 11 in the following example.

IntegerDigits[11,2]
(* {1,0,1,1} *)


Then use rules to convert each digit to the corresponding matrix, and form the dot product.

Apply[Dot,IntegerDigits[11,2]/.{0->e,1->d}]


Alternatively, select the appropriate matrix from a list.

Apply[Dot,{e,d}[[IntegerDigits[11,2]+1]]]