Given a number, n, create an n x n sized matrix with concentric squares of 1s from the outside in. There should be a gap between each square (represented by 0s).
If n is even, the centre of the matrix should be a 2 x 2 square of 0s or 1s, if it is odd it should be a 1 x 1 square.
The function should return the square matrix, S, and the number of squares, Sn, (in some cases this may only be one).
e.g. n = 7 1 1 1 1 1 1 1 1 0 0 0 0 0 1 1 0 1 1 1 0 1 1 0 1 0 1 0 1 1 0 1 1 1 0 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers18
Suggested Problems
-
Find the numeric mean of the prime numbers in a matrix.
9160 Solvers
-
Find all elements less than 0 or greater than 10 and replace them with NaN
15808 Solvers
-
Check to see if a Sudoku Puzzle is Solved
341 Solvers
-
Increment a number, given its digits
688 Solvers
-
Calculate the probability that at least two people in a group share the same birthday.
106 Solvers
More from this Author1
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!