Maximum value in multidimensional matrix
MDMAX Largest component in a multidimensional matrix.
For a matrix X, MDMAX(X) is the largest element in X.
[Y,I] = MDMAX(X) returns the indices of the maximum value in vector I.
When X is complex, the maximum is computed using the magnitude
MAX(ABS(X)). In the case of equal magnitude elements, then the phase
angle MAX(ANGLE(X)) is used.
NaN's are ignored when computing the maximum. When all elements in X
are NaN's, then the first one is returned as the maximum.
Example: If X = [2 8 4; then mDmax(X) is 9,
7 3 9]
and
[val,ind] = mDmax(X) returns val=9 and ind=[2 3]
Note: The vector ind can be used to access elements from X using this
neat trick:
sub = num2cell(ind)
val = x(sub{:});
Cite As
Naresh Vankayalapati (2024). Maximum value in multidimensional matrix (https://www.mathworks.com/matlabcentral/fileexchange/37392-maximum-value-in-multidimensional-matrix), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
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.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 |