Problem 56155. Return the middle element of an NxN square matrix where N is odd
Let's say you are given an NxN square matrix where N is always going to be an odd number:
x = [ 1 2 3
4 5 6
7 8 9 ]
Your function should return 5.
Edge Case: Your solution must be able to handle empty matrices, and return a NaN in that case like:
% Input Matrix
x = []
% Correct answer returned by your function
y = NaN
Solution Stats
Problem Comments
-
1 Comment
Christian Schröder
on 11 Nov 2022
The problem description doesn't match the test suite --- the input matrix can in fact be non-square.
Solution Comments
Show commentsProblem Recent Solvers21
Suggested Problems
-
Make a random, non-repeating vector.
8478 Solvers
-
Find the index of the largest value in any vector X=[4,3,4,5,9,12,0,4.....5]
368 Solvers
-
Find out sum of all elements of given Matrix
488 Solvers
-
Deleting an element in a matrix
457 Solvers
-
513 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!