MATLAB: Element Look-up in a vector

vector manipulation

Hi,
In the scenario where the vector h = [1 2 3 4 5]' and the vector p = [10 15 20 12 8]', it can be found that the maximum value in vector p is 20, using the max function. The position of this maximum in vector p is the 3rd element.
Is there a way of then allocating a new variable, say z for example, with the 3rd element from vector h, Thus making z = 3 ???
Many Thanks

Best Answer

[maxvalue, maxidx] = max(p);
z = h(maxidx);