Problem 44973. Create a "+" flag
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 commentsProblem Recent Solvers36
Suggested Problems
-
Read a column of numbers and interpolate missing data
2317 Solvers
-
Create a two dimensional zero matrix
501 Solvers
-
Remove element(s) from cell array
1757 Solvers
-
159 Solvers
-
String Array Basics, Part 1: Convert Cell Array to String Array; No Missing Values
1736 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!