Problem 43995. convert 2D array of ones and zeros to checkerboard array of [1,2] where the original array was ones and zero elsewhere
Given a 2D array of ones and zeros, generate an equivalent sized checkerboard array of ones and twos. The checkerboard pattern starts with 2:
[2,1,2,1,2; 1,2,1,2,1; 2,1,2,1,2];
Then set this checkerboard array to zero wherever the original was zero.
Solution Stats
Problem Comments
-
1 Comment
yurenchu
on 10 Jan 2017
You should add a test case where the last row and/or last column of x contains only zeroes.
Solution Comments
Show commentsProblem Recent Solvers26
Suggested Problems
-
Project Euler: Problem 10, Sum of Primes
1636 Solvers
-
Getting the indices from a vector
8693 Solvers
-
Rotate input square matrix 90 degrees CCW without rot90
594 Solvers
-
Create the following sequence : 0 1 1 4 9 25 64 169 ...
175 Solvers
-
317 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!