Search Comments and Ratings

go

   
Date File Comment by Comment Rating
19 Aug 2013 absmax Returns the value of the element with the largest absolute value in the input matrix. Author: Adam McNeilly 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 absmax Returns the value of the element with the largest absolute value in the input matrix. Author: Adam McNeilly 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 absmax Returns the value of the element with the largest absolute value in the input matrix. Author: Adam McNeilly Owen Brimijoin

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

A(abs(A)==max(abs(A(:))))

Hooray for logical indexing!

Comment only

Contact us