MATLAB: Is this function not recognizing the correct number of rows

functionrowvector

In this function I am taking a matrix m where each row holds a student's grades and each column is a different assignment, and returning the lowest of the highest grade that each student achieved in any assignment. When I do minmaxgrade([74, 72, 78; 67, 89, 90; 89, 92, 100; 100, 80, 90]) I am getting a weird answer, ans = 67 72 78 instead of just 78.
Here's my code:
function M=minmaxgrade(m)
[R,~]=size(m);
M=min(max(m,[],R));
end

Best Answer

Change the line
[R,~]=size(m);
to
R = 2;
You want to do your maximizing along the second dimension, not the fourth. Your matrix doesn't even have four dimensions. Matlab should have issued an error message. Did it?