Union Jack Matrix - MATLAB Cody - MATLAB Central

Problem 43801. Union Jack Matrix

Difficulty:Rate

Create a matrix of odd dimensions that has ones on both diagonals and dividing the matrix into 4 quadrants, resembling a square union jack flag. For example, if n=11:

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

Solution Stats

65.03% Correct | 34.97% Incorrect
Last Solution submitted on Jan 04, 2025

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers81

Suggested Problems

More from this Author11

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