Inserting the Calculated Number on Figure

12 ビュー (過去 30 日間)
manish sharma
manish sharma 2013 年 3 月 18 日
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!

採用された回答

Walter Roberson
Walter Roberson 2013 年 3 月 18 日
[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.
  3 件のコメント
Walter Roberson
Walter Roberson 2013 年 3 月 18 日
[maxy maxyidx] = max(Y);
x_at_max = X(maxyidx);
title( sprintf('The Peak of the curve is %f at x=%f', maxy, x_at_max));
manish sharma
manish sharma 2013 年 3 月 18 日
Brilliant, that worked Walter. Thanks for your help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Preprocessing についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by