MATLAB: Find the maximum in the array

arraymaximumvalue

Hello, I have an array of size x,y,z. Now, I would like to locate the maximum within all the values in the array. I want to know the value of x, y and z for this maximum value. Thank you very much in advance for your help!

Best Answer

A = rand(x, y, z);
[maxValue, maxIndex] = max(A(:));
[ix, iy, iz] = ind2sub([x, y, z], maxIndex);
[EDITED] Here "A" was created only as test data only. If you have the array already, you need the size() command to obtain the dimensions:
[maxValue, maxIndex] = max(A(:));
[ix, iy, iz] = ind2sub(size(A), maxIndex);