MATLAB: How to select the x-value of the maximum of a figure (without using ginput)

homework

I've got a figure (see attachment). I want to select the x-value of it's maximum. How do I do this?

Best Answer

I would use the max function with two output arguments, then use the index value to find the x-value:
[ymax,idx] = max(y);
xmax = x(idx);