help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

index of max element of a 4-D matrix


From: Tim Rueth
Subject: index of max element of a 4-D matrix
Date: Mon, 12 Apr 2010 00:28:25 -0700

I am currently using a for-loop to parse through a 4-D matrix to find the index of the maximum-value element.  I'm sure this can be done much simpler using commands like max() and find().  Conceptually, I'd like to just say:
 
max_idx = find(max(matrix_4d))
 
but I know this doesn't work because of how max() finds the max of each column, and returns a matrix itself.  So, maybe something like:
 
[max_matrix idx_matrix] = max(max(max(max(matrix_4d))))
 
This gives me the correct max value, but not the intended index, again, due to how the index is determined from each resulting max matrix.
 
Does anyone know a vectorized way of determining the index of the maximum-value element in a 4-D matrix that's faster than a for loop?
 
Thanks.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]