Alternating 1´s and 0´s in a matrix - MATLAB Cody - MATLAB Central

Problem 44854. Alternating 1´s and 0´s in a matrix

Difficulty:Rate

Given an odd number n, write a function that creates a matrix y with dimension nxn alternating 1's and 0's, and starting with 1 in the center of the matrix. For example, for n=3 one should get:

y = [0 0 0 ; 0 1 0; 0 0 0]

Solution Stats

59.09% Correct | 40.91% Incorrect
Last Solution submitted on Feb 01, 2025

Solution Comments

Show comments
Who Deserves Your Praise? Discover the New Contribution Widget!
...
We are excited to announce another update to our Discussions area: the...

Problem Recent Solvers25

Suggested Problems

More from this Author11

Community Treasure Hunt

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

Start Hunting!
Go to top of page