user2445472
user2445472

Reputation:

Convert matrix elements from decimal to binary

I have a matrix with decimal elements. I want to convert every element in this matrix to binary with a resolution of 8. What function should I use?

Upvotes: 0

Views: 1370

Answers (1)

wakjah
wakjah

Reputation: 4551

Use dec2bin:

>> dec2bin([10; 100; 255], 8)

ans =

00001010
01100100
11111111

The second parameter tells it to use at least N bits (where N==8 here).

Upvotes: 1

Related Questions