Max and Min of n-dimensional Matrices
Determines the minimum / maximum value and its index of an n-dimensional
matrix. E.g., for a 2D-Matrix x and y position of the min / max value are
returned, for a 3D-Matrix x, y and z position of min / max value are returned.
Syntax: [v,idx] = minN(A) / [v,idx] = minN(A)
Inputs:
A - the matrix of which the minimum / maximum value shall be found
Outputs:
v - the minimum / maximum value of A
idx - the index of v in matrix A
Example:
A(:,:,1) = [1,1,2;1,1,1;1,1,1];
A(:,:,2) = [1,1,1;1,1,1;1,1,1];
A(:,:,3) = [1,1,1;1,1,1;0,1,1];
[v1,idx1] = minN(A);
[v2,idx2] = maxN(A);
% v1 = 0, and idx1 = [3,1,3]
% v2 = 2, and idx2 = [1,3,1]
% it is A(3,1,3) = 0
% it is A(1,3,1) = 2
Cite As
Christopher (2024). Max and Min of n-dimensional Matrices (https://www.mathworks.com/matlabcentral/fileexchange/44758-max-and-min-of-n-dimensional-matrices), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- MATLAB > Mathematics > Elementary Math >
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.