Binary numbers - MATLAB Cody - MATLAB Central

Problem 34. Binary numbers

Difficulty:Rate

Given a positive, scalar integer n, create a (2^n)-by-n double-precision matrix containing the binary numbers from 0 through 2^n-1. Each row of the matrix represents one binary number. For example, if n = 3, then your code could return

>> binary_numbers(3)

ans =

     1     1     1
     0     0     0
     0     1     1
     0     1     0
     0     0     1
     1     0     0
     1     1     0
     1     0     1

The order of the rows does not matter.

Solution Stats

41.93% Correct | 58.07% Incorrect
Last Solution submitted on Feb 17, 2025

Problem Comments

Solution Comments

Show comments
MATLAB Without Borders: Connecting your projects with Python and other Open Source Tools.
On 27th February María Elena Gavilán Alfonso and I will be giving...
0
6

Problem Recent Solvers4547

Suggested Problems

More from this Author96

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Go to top of page