View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

Be the first to rate this file! 3 Downloads (last 30 days) File Size: 1.27 KB File ID: #41115 Version: 1.0




Returns the value of the element with the largest absolute value in the input matrix.

| Watch this File

File Information

Returns the value of the element with the largest abs value in the input matrix 'A'. Input 'A' must be numeric, but can be any size and shape.

This is useful because it eliminates iterating through all the dimensions of a matrix.

A=[-5 3 2 3; 3 2 1 4];
absmax(A) will return -5

absmax(A) will return 643

Required Products MATLAB
MATLAB release MATLAB 8.1 (R2013a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
19 Aug 2013 Adam McNeilly

Jan Simon's solution is more efficient.

W. Owen Brimijoin's solution returns a matrix when there is more than one max value.

Comment only
05 Apr 2013 Jan Simon

Jan Simon (view profile)

Even more efficient than W.Owen Brimijoin's suggestion:

[dummy, index] = max(abs(A(:));
result = A(index);

Linear indexing beats the logical indexing here.

Comment only
05 Apr 2013 Owen Brimijoin

What about this alternate (and arguably simpler) means of solving the problem:


Hooray for logical indexing!

Comment only

Contact us