Maximum value in multidimensional matrix

MDMAX Largest component in a multidimensional matrix.
333 Downloads
Updated 3 Jul 2012

View License

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
Created with R14
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Logical in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0