MATLAB: Get the max value and indices of a fourth order tensor.

MATLABtensor

Hello, i created a function that gives the efficiency of a machine given 4 imputs. Each imput belongs to a vector so in the end i get a 4th order tensor. I'd like to write a function that finds the maximum value in the tensor and also returns it position (i.e indices). Any help would be appreciated.

Best Answer

If T is the array, then
[M,idx] = max(T(:))
will give the maximum value and linear index to that value.
You can then use ind2sub to get from the linear index to the subscript indices.
Related Question