MATLAB: Inserting the Calculated Number on Figure

figurenumber on plotpeakstring on plottext on plot

Hey,
My code plots matrix Y with respect to matrix X and it calculates max(Y). I want to:
(i) Determine the number in [X] corresponding to (max(Y)), and (ii) Display both of these numbers on the plot. (Something like: "The Peak of the curve is 200 at 660)
where 200 is the peak of the plotted curve at x=600.
Any kind of help in this regard will be greatly appreciated.
Thanks!

Best Answer

[maxy maxyidx] = max(Y);
x_at_max = X( subs2indx(size(X), 1:size(X,1), maxyidx) );
Your (ii) is written as if there is only a single value resulting from max(Y), but max(Y) is going to give you a maximum for every column, as you indicate that Y is a matrix.