Given two odd numbers, [m, n], return a matrix of size m x n which has all elements of the centre column and centre row set as 1, and all other elements in the matrix set as 0.
For example, [m, n] = [3, 3] would return
[0, 1, 0; 1, 1, 1; 0, 1, 0]
If either m or n is even, there is no row of ones (for m) or no column of ones (for n). So [m, n] = [4, 3] would return
[0, 1, 0; 0, 1, 0; 0, 1, 0; 0, 1, 0]
[m, n] =[4, 4] would return
[0, 0, 0, 0; 0, 0, 0, 0; 0, 0, 0, 0; 0, 0, 0, 0]
Solution Stats
Problem Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers39
Suggested Problems
-
Find all elements less than 0 or greater than 10 and replace them with NaN
15782 Solvers
-
2364 Solvers
-
Solve the set of simultaneous linear equations
496 Solvers
-
Given a matrix, swap the 2nd & 3rd columns
1263 Solvers
-
Find my daddy long leg (No 's')
2727 Solvers
More from this Author3
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!